![]() |
match items in an array against text - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: match items in an array against text (/showthread.php?tid=17730) |
match items in an array against text - El Forum - 04-14-2009 [eluser]matt2012[/eluser] Ok so I have a large array and a large text to search my aim to create a new array based on what items in the large array are found in the text so something like Code: $myarray = array("apple juice","nice cake","ice cream",...) given that its a large array and large text this seems inefficient is their a better way to tackle this? match items in an array against text - El Forum - 04-14-2009 [eluser]GSV Sleeper Service[/eluser] you may be better off using preg_match_all() http://uk3.php.net/manual/en/function.preg-match-all.php I expect there's an even neater solution, but I'm not really in the mood for trawling through the php docs! match items in an array against text - El Forum - 04-14-2009 [eluser]davidbehler[/eluser] As far as I can tell there is no build-in function that does what you need. On the strpos - Manual you can find a custom function similar to yours: Code: function strposa($haystack ,$needles=array(),$offset=0){ |