Vote count:
0
i have a text file, with a lot of data in it. i've gotten as far as extracting field names between character statements.
what i would like my code to do is scan the ENTIRE text file. for some reason it stops with the first occurrences of the characters/string.
<?PHP
//First, open the file. Change your filename
$file = "datafile1.txt";
$handle = fopen($file, "r");
$contents = fread($handle, filesize($file));
for ($i=0; $i=100; $i+10){
$word1='"cat_id';
$word2='"category"';
$a = strpos($contents, $word1);
$b = strpos($contents, $word2);
$between=substr($contents, $a, ($b - $a));
echo $between;
//////////////////////////////////
$word1='"category';
$word2='"name"';
$c = strpos($contents, $word1);
$d = strpos($contents, $word2);
$between=substr($contents, $c, ($d - $c));
echo $between;
////////////////////////////////////
$word1='"name';
$word2='"description"';
$e = strpos($contents, $word1);
$f = strpos($contents, $word2);
$between=substr($contents, $e, ($f - $e));
echo $between;
}
fclose($handle);
?>
i got a return
"cat_id": "16349", "category": "Adventure", "name": "Assassin's Creed IV Black Flag - Xbox 360",
but it stops there. where there are repeated cat_id's and categories, and names of... well, computer games. i need to scan the entire text file so the search repeats itself. hopefully get a list out of the output. of the games and categories.
thanks.
asked 24 secs ago
Finding Recurring String in a TEXT file using PHP
Aucun commentaire:
Enregistrer un commentaire