这是一个由会话传递的数组。
这是我的代码:
var_dump($result);
array(1) {
["result"]=>
array(3) {
["status"]=>
bool(false)
["message"]=>
string(4) "test"
["type"]=>
string(5) "error"
}
array_key_exists('type', $result)) //returns false
此外,我注意到将某些内容分配给关键的“消息”会产生另一个“消息”密钥,该密钥可以访问...
答案 0 :(得分:1)
这是因为type
密钥存在于数组result
$result
数组中
array_key_exists('type', $result['result'])) // returns true
答案 1 :(得分:1)
你必须写
array_key_exists('type', $result['result']);
我猜这与分配'消息'的问题相同。你应该写
$result['result']['message'] = 'new message';