I have a text file named teste.txt
, in it I have the following code:
<ID>490901</ID>
<ID>28602</ID>
<ID>298174</ID>
<ID>1081022</ID>
I want to create a script to display only the first line:
<ID>490901</ID>
File in php:
<?php
$search = '<ID>';
$lines = file('teste.txt');
foreach($lines as $line)
{
if(strpos($line, $search) !== false)
echo $line;
}
?>
But my script in php gives me the following result:
490901 28602 298174 1081022
How do I get only 490901
?