On Thu, 26 Jul 2001 05:49, David OBrien wrote:
> I'm having a heck of a time getting something to work like it should
>
> I have a script which reads a list of words one per line
> I want it to display the length of the word a tab then the word. No
> matter how I code it it still only shows the word alone on strlen. Any
> ideas?
>
> <?
> $handle = fopen ("./ospd3.txt", "r");
> while (!feof($handle)) {
> $wordlist[]=fread($handle,4096);
> }
> fclose($handle);
> uasort($wordlist, "sortbylength");
> foreach ($wordlist as $word) {
> $lent = strlen($word);
> print "$lent"."\t"."$word"."\n";
> }
> exit;
>
>
> function sortbylength($arr,$brr) {
> $alen = strlen($arr);
> $blen = strlen($brr);
> if ($alen == $blen) {
> return 0;
> }
> return ($alen > $blen) ? -1 : 1;
> }
> ?>
>
> sample of the ospd3.txt
<SNIP>
> Thanks
If you are outputting that to a browser, be aware that, unless the output
is enclosed in <PRE> tags, the browser will ignore the tabs. Tabs,
multiple spaces and end of line dharacters are all ignored.
Alternatively, you could build it into a <TABLE> structure.
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
Not a real tagline, but an incredible soy substitute.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]