Results 1 to 2 of 2

Thread: 2 PHP Questions

  1. #1
    rsitogp
    Guest

    2 PHP Questions

    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!

  2. #2
    denniswrenn
    Guest
    1)

    PHP Code:
    <?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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width