Hi ,traing to explode list like
1. one.gif
2. two.gif

$datain= file_get_contents($filename);


$lines=explode("\n",$datain);
  for($i=0;$i<sizeof($lines);$i++)
  {
  echo $lines[$i].'<br>';
  $images=explode(":",$lines[$i]);
  }

Recommended Answers

All 2 Replies

Exactly what are you trying to achieve? :p

$datain= file_get_contents($filename);
$lines=explode("\n",$datain);
  for($i=0;$i<sizeof($lines);$i++)
  {
  echo $lines[$i].'<br>';
  $images=explode(":",$lines[$i]);
  }

If you want to read something line by line do it like this:

$myFile = "myFile.txt";
$fh = fopen($myFile, 'r');

//fgets gets the content line by line, and this while loop reads it until if comes to //an empty line
while(($line = fgets($fh))!= null)
{
   $image = explode(":",$line);
}

This will read line by line, and for reach line, take it and explode it by ":" character. So at the end of each iteration of the for loop, you will have for example $images[0]="one.gif" and $images[1]="two.gif".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.