Reply to array push

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация