Hello.
There is an array:
$array = array(); $array[] = 'привет всем'; $array[] = 'privet vsem';
What function can I find an array of the entry "all"?
Developments:
if(array_search('всем', $array)) echo '1';
If I understand the question correctly, then there seems to be no such function, but it’s not a problem to write one
function my_array_search($needle, $array) { $result = array(); foreach($array as $key => $value) { if(strpos($value, $needle) !== false) { $result[$key] = $value; } } return $result; }
$array1 = array("всем прив", "привет", "всем", "всем тут привет", "яяя"); $str='всем'; function my_seach($var) { global $str; return (strpos($var, $str) !== false); } print_r (array_filter($array1, "my_seach"));
is displayed
Array ( [0] => всем прив [2] => всем [3] => всем тут привет )
Source: https://ru.stackoverflow.com/questions/134421/
All Articles