PDA

Click to See Complete Forum and Search --> : 2 PHP Questions


rsitogp
Jul 30th, 2001, 12:06 PM
1. How can I search a textfile for a string and return the whole line?
2. How can I sort by a certin number word (like "this is a test" and I want to sort by second word)

Thanks!

denniswrenn
Jul 30th, 2001, 12:30 PM
1)


<?php
$filearr = file("filename.txt");
$arrlen = count($filearr);
$tofind = "hello";

for($i = 0; $i < $arrlen; $i++)
{
$pos = strstr($filearr[$i], $tofind);
if($pos)
{
$found = $filearr[$i];
break;
}
}
echo $found;
?>


I don't understand what you mean by number two.