PHP explode not filling in array spot 0

Posted by Billy Winterhouse on Stack Overflow See other posts from Stack Overflow or by Billy Winterhouse
Published on 2010-03-17T00:03:25Z Indexed on 2010/03/17 0:11 UTC
Read the original article Hit count: 714

Filed under:
|

I have a file we will call info.txt under UNIX format that has only the following in it:

#Dogs
#Cats
#Birds
#Rabbits

and am running this against it:

$filename = "info.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd,filesize ($filename));

fclose ($fd);
$delimiter = "#";
$insideContent = explode($delimiter, $contents);

Now everything looks to be working fine except when I display the array I get the following.

[0] => 
[1] => Dogs
[2] => Cats
[3] => Birds
[4] => Rabbits

I checked the .txt file to make sure there wasn't any space or hidden characters in front of the first # so I'm at a loss of why this is happening other than I feel like I'm missing something terribly simple. Any ideas?

Thanks in advanced!

© Stack Overflow or respective owner

Related posts about php

Related posts about explode