ShivaGupta Posted July 27, 2013 Share Posted July 27, 2013 <?php $mid= explode("\n",file_get_contents("data.txt")); for($i=0; $i<count($mid); $i++) { $myid = explode(",",$mid); $uid = $myid[0]; $pwd= $myid[1]; echo "<hr><b><font color=brown>Summary For ID : ".$uid."".$pwd."</font></b><hr>"; } ?> geting this error Warning: explode() expects parameter 2 to be string, array given in /home/content/65/11169265/html/x/index.php on line 5 data.text yournumber,password yournumber,password yournumber,password yournumber,password yournumber,password yournumber,password yournumber,password yournumber,password plz help me out Link to comment https://forums.phpfreaks.com/topic/280576-warning-explode-expects-parameter-2-to-be-string-array-given-in-homecontent6511169265htmlxindexphp-on-line-5/ Share on other sites More sharing options...
Barand Posted July 27, 2013 Share Posted July 27, 2013 $mid is an array that you created on line 2. Read the error message, it's quite plain. Try $myid = explode(",",$mid[$i]); Link to comment https://forums.phpfreaks.com/topic/280576-warning-explode-expects-parameter-2-to-be-string-array-given-in-homecontent6511169265htmlxindexphp-on-line-5/#findComment-1442441 Share on other sites More sharing options...
Psycho Posted July 27, 2013 Share Posted July 27, 2013 $mid= explode("\n",file_get_contents("data.txt")); for($i=0; $i<count($mid); $i++) A for() loop to iterate over an array? Link to comment https://forums.phpfreaks.com/topic/280576-warning-explode-expects-parameter-2-to-be-string-array-given-in-homecontent6511169265htmlxindexphp-on-line-5/#findComment-1442444 Share on other sites More sharing options...
jazzman1 Posted July 27, 2013 Share Posted July 27, 2013 Or just get all lines from the pointer. <?php $handle = fopen("data.txt", "r"); if ($handle) { while (($lines = fgets($handle, 4096)) !== false) { echo "<hr><b><font color=brown>Summary For ID : $lines</font></b><hr>"; } if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); } Source - http://php.net/manual/en/function.fgets.php Link to comment https://forums.phpfreaks.com/topic/280576-warning-explode-expects-parameter-2-to-be-string-array-given-in-homecontent6511169265htmlxindexphp-on-line-5/#findComment-1442446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.