|
Posted by Harris Kosmidhs on 08/02/07 13:00
Hello. I have a function which stores a ; seperated file in an array
like this
function readdata($filename,$seperator=";") {
$output=array();
if( ! file_exists($filename)) return $output;
$fp=fopen($filename,"r") ;
while(!feof($fp)) {
$tmp=fgets($fp);
if(strpos($tmp,"#",1)<>1) {
$tmpsp=split($seperator,$tmp);
array_push($output,$tmpsp);
}
}
print_r($output);
}
print_r shows:
Array ( [0] => Array ( [0] => Blah Blah[1] => http://xxx [2] => xxxxxx )
[1] => Array ( [0] => Blah2 [1] => http://yyyy [2] => yyyyy) )
Now I want to loop to every element of $output and print every line like
this:
foreach($output as $o) {
print_r($o);
}
But I get a Warning: Invalid argument supplied for foreach().
Any help?
Harris
Navigation:
[Reply to this message]
|