[Solved] Best method question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [Solved] Best method question (/showthread.php?tid=64502) |
[Solved] Best method question - wolfgang1983 - 02-26-2016 My foreach loop picks up files and folders. But I am still having issue because when original_image is a folder it throws error. Code: A PHP Error was encountered I am not sure the best method of where to use if is file or a if is dir? Because I use a input get as well. Any suggestions? PHP Code: $this->load->helper('directory'); RE: Best method question - Diederik - 02-26-2016 The directory_map() function gives you back a nested array. If you loop through it you should perform an extra verification to check if the value is a string (containing your image file name) or an array (containing all the files in the sub directory). PHP Code: foreach ($cached_images as $position => $image) { RE: Best method question - wolfgang1983 - 02-26-2016 (02-26-2016, 04:46 PM)Diederik Wrote: The directory_map() function gives you back a nested array. If you loop through it you should perform an extra verification to check if the value is a string (containing your image file name) or an array (containing all the files in the sub directory). thanks for that I will read more on is_string that is a new one for me. |