// get contents of a file into a string
$filename = "./areacode.log";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$elements=explode("\n",$contents) ;
foreach($elements as $value) {
if (stristr($value,"California ")) { // If Number California is found it will print all values co Calif
echo "$value<br>";
}
}
?>
Original File
Alabama(1)251
Alabama(1)256
Alabama(1)334
Alaska(1)907
Arizona (1)480
Arizona (1)520
Arizona (1)602
Arizona (1)623
Arizona (1)928
Arkansas(1)479
Arkansas(1)501
Arkansas(1)870
California (1)209
California (1)213
California (1)310
California (1)323
California (1)408
California (1)415
No hay comentarios:
Publicar un comentario