我有这个数组:
$variableNames = [
'x1',
'x2',
'x3',
'x4',
'x5',
'x6',
'x7'
];
但是,当我使用这样的 array_key_exists 函数时:
array_key_exists('x3', $this->variableNames)
它返回false
。但是,如果我有这个数组:
$variableNames = [
'x1' => null,
'x2' => null,
'x3' => null,
'x4' => null,
'x5' => null,
'x6' => null,
'x7' => null
];
它返回true
。我怎样才能使用第一个数组,并得到true
?在第一个数组中,值也为空,就像第二个数组一样。那么,为什么第一个数组返回false
,第二个数组返回true
呢?