e.g。输入数组
array ([0] => Array
(
[date] => 2016-11-16
[cook_book_id] => 89
[occassion] => Not set
)
[1] => Array
(
[date] => 2016-11-16
[cook_book_id] => 90
[occassion] => Diwali
)
[2] => Array
(
[date] => 2016-11-16
[cook_book_id] => 95
[occassion] => Not set
)
[3] => Array
(
[date] => 2016-11-17
[cook_book_id] => 95
[occassion] => Not set
)
)
输出应
array([0] => Array
(
[date] => 2016-11-16
[cook_book_id] => 89
[occassion] => Diwali
)
[1] => Array
(
[date] => 2016-11-17
[cook_book_id] => 95
[occassion] => Not set
)
)
在输入数组中,“date”和“Not Set”值从输入数组重复我希望唯一的日期值与occassion名称“diwali”(高优先级),如果没有则可以是任何值,则默认值应为“Not Set” “即如果未设置应该覆盖”排灯节“,否则它应该是”未设置“
答案 0 :(得分:0)
如果我理解正确的话,可能就是这样。
<?php
$today = date('Y-m-d');
foreach($array as $key => $value){
if($value['occassion'] === 'Not Set' && $value['date'] === $today){
$array[$key]['occassion'] = 'Birthday';
}
}