/ Published in: PHP
Searches all array elements for a given substring. Returns an array of found key=>value pairs or false if not found.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * * @Search for substring in an array * * @param string $neele * * @param mixed $haystack * * @return mixed Array or false if not found * */ function substr_in_array($haystack, $needle) { /*** cast to array ***/ /*** map with preg_quote ***/ /*** loop of the array to get the search pattern ***/ foreach ($needle as $pattern) { return $found; } } /*** if it is not found ***/ return false; }
URL: http://368design.com