php set lines in a text file to an array value -


im looking following

$file = ('file.txt'); $fopen($file); 

then read each line file individually , set specific array

like so

read $file $line1 set $array[0] read $file $line2 set $array[1] read $file $line3 set $array[2] 

i use these arrays created lines on text file in plain text this:

$urlout = file_get_contents("http://myurl.com/?=$line1"); echo $urlout; $urlout2 = file_get_contents("http://myurl.com/?=$line2"); echo $urlout2; $urlout3 = file_get_contents("http://myurl.com/?=$line3"); echo $urlout3; 

so if array 123.22.11.22 link this:

$line1 = array[0] (123.22.11.22) $urlout = file_get_contents("http://myurl.com/?=$line1"); echo $urlout; 

and result be

info 123.22.11.22 more info more

modified answer per change indicated user :

reading 2 lines on each loop..

$lines = file("file.txt"); for($i=0 ; $i<count($lines); $i=($i+2) ) {     echo file_get_contents("http://myurl.com/?=".$lines[$i]);     echo file_get_contents("http://myurl.com/?=".$lines[($i + 1)]); } 

imp note : url can used filename file_get_contents() function, if fopen wrappers have been enabled.


Comments