我有复选框字段,我想设置条件,如果$array[und][1][value]
等于特殊字符打印的东西......
喜欢这样:
switch ($array) {
case "1": print 'Starts'; break;
case "3": print 'Roads'; break;
case "7": print 'Flys'; break;
case "9": print 'Awesome'; break;
}
复选框数组:
Array
(
[und] => Array
(
[1] => Array
(
[value] => 1
)
[9] => Array
(
[value] => 3
)
[42] => Array
(
[value] => 7
)
[61] => Array
(
[value] => 9
)
)
)
答案 0 :(得分:1)
您必须循环$array['und']
或$array[LANGUAGE_NONE]
:
foreach ($array['und'] as $item) {
switch ($item['value']) {
// ...
}
}
您还可以获取值:
$values = array_column($array['und'],'value')) ; // [1,3,7,9]