Search files 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: Search files question (/showthread.php?tid=68812) |
Search files question - wolfgang1983 - 08-29-2017 How can I search for file with any of the key search word in string. Currently example if my key search is number 3 it will find files that start with the number 3.jpg How ever for example I would like to be able to find files that have 123.jpg also. I need to be able to search for letters and numbers. PHP Code: if (null !==($this->input->get('directory'))) { RE: Search files question - InsiteFX - 08-29-2017 From stackoverflow. Consider using preg_replace_callback. Use this regex: (images/([0-9]+)[^"]+") Then, as the callback argument, use an anonymous function. Result: You should be able to modify this to work for you. PHP Code: $output = preg_replace_callback( Give it a try. RE: Search files question - wolfgang1983 - 08-29-2017 (08-29-2017, 03:36 AM)InsiteFX Wrote: From stackoverflow. OK I will I have also tried PHP Code: $files = glob($directory . '/*{' . $filter_name . '}*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE); Seems to work what you think of that above? Because I need to search letters and numbers. |