【发布时间】:2018-05-20 21:00:28
【问题描述】:
如果条件匹配,我想从多数组中获取变量的特定值。
当我打印我的数组时:
print_r($myarray);
给出这样的数组:
Array
(
[0] => Array
(
[id] => 21 //check for this value
[customer_id] => 12456 //get this value
[date] => 12-06-2017
)
[1] => Array
(
[id] => 15
[customer_id] => 12541
[date] => 12-06-2017
)
[2] => Array
(
[id] => 12
[customer_id] => 25415
[date] => 12-06-2017
)
)
如果 ID 与 21
匹配,我正在尝试获取 客户编号foreach ($myarray as $array){
if($array[][id] == "21"){ //this is where I'm making mistake
$cust_id = $myarray[]['customer_id'];
return $cust_id;
}
}
【问题讨论】:
-
感谢您找到重复的人,这对如何搜索也有很大帮助。
标签: php