In php we have ar开发者_如何转开发ray_search() to search a value in an array. According to my knowledge it can search only one value at a time. How to search more that one values in an array. Are there any functions to do so.
Thanks
I'm not sure if there is a function for it, but you could do that in a foreach loop quite easily.
<?php
$array('some', 'values', 'here');
$values = array('values', 'to', 'find');
foreach($values as $v) {
$key = array_search($v, $array):
if ($key) {
$new_array[] = $array[$key];
}
}
?
try this:
$array = array('some', 'values', 'here');
$values = array('values', 'to', 'find');
foreach($values as $v) {
$key = array_search($v, $array);
if ($key) {
$new_array[] = $array[$key];
}
}
精彩评论