我想用
type
键来回显数组值,这是我的代码,
foreach ($sam as $key => $sa) {
foreach ($sa as $s) {
echo $s['type'];
}
}
这是数组的内容
$sam
:
array (size=1)
0 =>
array (size=5)
'type' => string 'days' (length=4)
'bookable' => string 'no' (length=2)
'priority' => int 10
'from' => string '1' (length=1)
'to' => string '1' (length=1)
我不明白为什么我的一系列 foreach 调用会导致
警告:非法字符串偏移“type”
你能帮我回显
type
值吗?
每个人只需要一个:
foreach ($sam as $s) {
echo $s['type'];
}