CodeIgniter Forums

Full Version: help with directory_map
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]matches[/eluser]
Hi,

I am looping through a directory and displaying the images in it. The code below successfully loops through all files but the last item is "Array"

How can avoid displaying the "Array" $item? The if ($item != "Array"){ is not working.

Thanks

Code:
$map = directory_map('./property_images/' . $row->id);
                if ($map){
                    foreach($map as $item):
                        if ($item != "Array"){
                            echo '<img >id . '/thumbs/' . $item . '" />';
                        }                    
                    endforeach;
                }

Code:
<img src="http://localhost/property_images/34/thumbs/1.jpg">
<img src="http://localhost/property_images/34/thumbs/2.jpg">
<img src="http://localhost/property_images/34/thumbs/3.jpg">
<img src="http://localhost/property_images/34/thumbs/4.jpg">
<img src="http://localhost/property_images/34/thumbs/Array">

El Forum

[eluser]Mirge[/eluser]
if(!is_array($item)) { ... }

El Forum

[eluser]matches[/eluser]
great, thanks!