$arr = array(
'application' => array (
'environment' => 'development',
'mode_debug' => 1,
'key' => '123456abcdefg',
'debug_soft' =>
'firephp',
'aaa' => array (
'bbb' => '111',
'ccc' => '222',
'ddd' => array (
'eee' => '12345',
),
),
),
'database' => array (
'host' => 'localhost',
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
),
);
if(isset($arr["application"]["aaa"]["ddd"]["eee"]['out']) && !empty($arr["application"]["aaa"]["ddd"]["eee"]['out'])){
echo "a";
echo '<br />';
var_dump($arr["application"]["aaa"]["ddd"]["eee"]['out']);
}else{
echo "b";
}
返回:
a
string(1) "1"
但是'$arr'数组中没有'out'索引,那么为什么它返回'string(1)“1”'?
该手册没有帮助,因为它只对一维数组进行采样:
$a = array ('test' => 1, 'hello' => NULL);
var_dump( isset ($a['test']) ); // TRUE
var_dump( isset ($a['foo']) ); // FALSE
var_dump( isset ($a['hello']) ); // FALSE