Is there a standard function to determine if any value is in an array?
Like strrpos () only for arrays.
If not, tell me the best possible solution for this task.
2 answers
// по значению in_array($value, $array) // по ключу isset($array[$key])
|
Yes! There is a lot of stuff here. Starting from " array_intersect()
", which returns elements matched in two arrays (compared and source), and ending with the method "snapshots" of all the elements of the array into a string and only then search in it. The second option can be done like this:
$arr=array(1,2,3,4,5); $str=implode('',$arr); $str2 = strpos("34",$str); echo($str2); // вывод позиции вхождения в "массив" строки "34"
|