Ok, this is probably something simple, but I just cant figure it out. I'm reading a directory, grabbing file names, and using those filenames to display images.
Simple code:
$srcpath = "images/cars/".$car['carID'];
$dir_handle = @opendir($srcpath);
$photos = array();
if ($dir_handle) {
while (false !== ($photo = readdir($dir_handle))){
if($photo!="." && $photo!=".." && strpos($photo,'.txt')===false && strpos($photo,'htaccess')===false){
$photos[] = $photo;
}
}
}
sort($photos);
print_r($photos);
The problem is the output on my computer vs my web hosting company's server. On my machine, I get this response, which is what I expect...
Array (
[0] => 01_right.jpg
[1] => 02_rear.jpg
[2] => 03_front.jpg )
When I upload the script to my server and run it, the $photo seems to never clear...
Array (
[0] => 01_right.jpg
[1] => 01_right.jpg02_rear.jpg
[2] => 01_right.jpg02_rear.jpg03_front.jpg )
Why is is appearing differently on my computer vs the server? Any idea why the subsequent array values seem to get concatenated?
I'm confused!