My array like this :
$myArray = array(
array(
'uid' => '100',
'name' => 'Michael',
'pic_square' => 'urs121'
),
array(
'uid' => '200',
'name' => 'machavent',
'pic_square' => 'urs222'
),
array(
'uid' => '300',
'name' => 'Ayem',
'pic_square' => 'urs333'
),
array(
'uid' => '400',
'name' => 'Bucin',
'pic_square' => 'urs444'
),
array(
'uid' => '500',
'name' => 'Bangcad',
'pic_square' => 'urs555'
)
);
this my function :
function filterElement($array, $key, $value){
foreach($array as $subKey => $subArray){
if($subArray[$key] != $value){
unset($array[$subKey]);
}
}
return $array;
}
this working fine if I just need get data from uid=100
$mydata = '100';
$array = filterElement($myArray, "uid", $mydata);
my results
But how if I want to get data from uid = [100,300] ?
I'm trying to call like this
$mydata = ['100','300'];
$array = filterElement($myArray, "uid", $mydata);
and change my function to
function filterElement($array, $key, $value){
foreach($array as $subKey => $subArray){
for($i=0;$i<count($value);$i++){
if($subArray[$key] != $value[$i]){
unset($array[$subKey]);
}
}
}
return $array;
}
and the results is
array(0) {
}
so my problem is how to filter data using multi value from multi dimensional array.
