There is an array of the form:
array(3) { [0]=> string(*) "test.ru-111.11111.111" [1]=> string(*) "site2.ru-2222.22.222" [2]=> string(*) "test.in-333.333.333" } I need to find a value in it (more precisely, the number under which this value is written in the array), for example, test.ru , I do this:
array_search('test.ru', $array); does not find. A
array_search('test.ru-111.11111.111', $array); finds
But it is clear why ... How to make the word that comes to - .
Provided that the $array cannot be output in a loop.
//////////////////////////
foreach($new_arr as $list_d_ip) { $iskomii = explode('-', $list_d_ip); $iskomii = str_replace(' ', '', $iskomii[0]); $patt = '/'.$iskomii.'-/'; $ss = preg_grep($patt, $array); var_dump($ss); } array(3) { [0]=> string(26) "zesiduwyk.ru -11.11.11.11 " [1]=> string(27) "edeziragaj.ru -2222.222.22 " [2]=> string(13) "test.ru-00000" }