There is an array:

$array = array(); $array[] = 'привет всем'; $array[] = 'privet vsem'; 

What function can I find an array of the entry "all"?


 if(array_search('всем', $array)) echo '1'; 

    2 answers 2

    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] => всем тут привет ) 
      • Not the best solution, here are needed. For example, add to the array a phrase containing the word "everywhere" and the function of this element of the array "for the native" will be primit. - Deonis
      • as the question was posed, the answer was received. The question does not say that the entry should be just a separate word (Yes, I think the author is more the question is not how to find the entry for a separate element of the array, but how beautiful it is to do for all elements of the array - Ale_x