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
megacities
memorising
nitpickier
outpowered
outslicked
pinwheeled
prebooking
ratcheting
rebreeding
redialling
reexposing
repatching
romanising
showbizzes
sparkliest
suctioning
sunporches
vitreouses
whatnesses
windsurfed
zombifying
backdropped
backfitting
beglamoring
chainsawing
coanchoring
deadlifting
Thanks
--
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]