Jump to content

Warning: explode() expects parameter 2 to be string, array given in /home/content/65/11169265/html/x/index.php on line 5


ShivaGupta

Recommended Posts

<?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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.