我有一個數組沾到var_dump($array)
的情況下的附加組件:
array(1) { [""]=> NULL }
如何能我檢查這是真的還是假的? 如果數組被設置,它將得到例如
array(1) { ["test"]=> string(2) "test" }
我試圖
if ($array == NULL)
if ($array[""] == NULL)
if ($array[""] == "NULL")
if ($array == "NULL")
我有一個數組沾到var_dump($array)
的情況下的附加組件:
array(1) { [""]=> NULL }
如何能我檢查這是真的還是假的? 如果數組被設置,它將得到例如
array(1) { ["test"]=> string(2) "test" }
我試圖
if ($array == NULL)
if ($array[""] == NULL)
if ($array[""] == "NULL")
if ($array == "NULL")
「」作爲數組索引是有點嚇人......
因爲$數組[0]作爲第一個元素都不行,你可以試試這個弄清楚,如果數組節點是空的:
$fillCount = 0;
foreach ($arrData as $key => $value)
{
if (!is_null($value)) $fillCount++;
}
if ($fillCount <= 0)
{
// nothing useful in the array
}
else
{
// useful content in the array
}
謝謝你,這工作 –
var_dump(is_null($array[""]));
如果你的意思是檢查,如果值爲null或不是你可以使用空:
if(empty($array[""]))
//element is null
else
//element is not null
肯定數組不爲空,因爲它有一個元素(數組(1))
你已經試過了什麼? – DevlshOne
if((count($ array)== 1)&&!$ array [「」]) – elnabo
你是什麼意思*檢查它是真是假* –