我有一个多维数组,如下所示。在当天的阵列中,它有各种各样的日子,有工作日和非工作日。现在我想先考虑first =“working”作为start_date 你可以帮帮我吗。感谢
Array
(
[error] => 0
[data] => Array
(
[start_date] => 2018-03-11
[end_date] => 2018-03-21
[days] => Array
(
[0] => Array
(
[type] => non_working
[sub_type] => weekend
[sub_sub_type] =>
[date] => 2018-03-11
)
[1] => Array
(
[type] => working
[sub_type] =>
[sub_sub_type] =>
[full_date] => 2018-03-12
)
[2] => Array
(
[type] => working
[sub_type] =>
[sub_sub_type] =>
[full_date] => 2018-03-13
)
)
)
)
我现在尝试这个:
$i=0;
$var = array();
foreach($arr['data']['days'][$i] as $var) {
if($var['type'] == 'working') {
break;
}
}
答案 0 :(得分:1)
返工$arr['data']['days'][$i]
至$arr['data']['days']
:
$start = null;
foreach($arr['data']['days'] as $var) {
if($var['type'] == 'working') {
$start = $var['date'];
break;
}
}