How do i get a line from a file. For ie: line.txt
1 California 2 New York 3 Texas
How Do I grab New York from the line.txt file?
Thank you.
Piece of Cake
use explode
$split = explode("\n", $text);
you will get every line in anothe 'variable';
$split[0] will be the first, $split[1] will be the second line and so on and so on.
For more info: http://www.php.net/manual/en/function.explode.php
Gr.
Kasper
Much easier:
It's already in a txt file, so use the function file().
<? $myfile = file("file.txt"); echo $myfile[2]; // Prints '2 New York'. $split = explode(" ", $myfile[2]); echo $split[1]; // Prints 'New York'. ?>