I have he next array looks like:
array:50 [▼
0 => array:39 [▶]
1 => array:39 [▶]
2 => array:39 [▶]
]
So I want to get arrays with a value in common, for example:
array:39 [▼
"id" => 121
"user" => 368
]
array:39 [▼
"id" => 121
"user" => 3687
]
array:39 [▼
"id" => 500
"user" => 452
]
I want to get the two arrays with the attribute id 121, I was trying to looping the array with foreach looks like:
foreach ($info as $val){
foreach($info as $f ){
if($f["id"]==$val["id"]){
//get the multiple arrays
}
}
}
So, I can't get all the arrays, some idea to how can do that?
foreach($info as $key => $f ) { if ($f['id']==121) {var_dump($info[$key]);}}foreach ($info as $val)thenforeach($info as $f ). The inner loop should be over$val, not$infoagain.array_filterhere, with a custom callback that compares each element'sidkey to your desired value.$filtered = collect($array)->where('id', '=', 121)