This article mainly shares with you how in_array in PHP compares the same values in the array and splices the arrays. I hope it can help you.
$right = array(1) { [0] => string(18) "贷后管理中心" }
$name_ok的值 string(12) "系统设置" string(12) "员工管理" string(18) "贷后管理中心" string(12) "业务管理"
Final result
{ ["daihou"]=> array(1) { ["name"]=> string(18) "Post-loan management center" }
Code
foreach ($menu_list as $k=>$v){ $name_ok = $v['name']; dump($name_ok); if(in_array($name_ok,$right)){ $data[$k] = $v; } }
Related recommendations:
php in_array function checks whether a certain value exists in the array
Usage of in_array function in php
10 recommended content of in_array()
The above is the detailed content of In_array in php compares the same values in the array and splices the arrays. For more information, please follow other related articles on the PHP Chinese website!