Array_key_exists () function Use problem
$res array, using Print_r ($res), after the statement output:
Array ([0] = = Array ([tagname] = kf_fic01341. TOTALIZERA_2.PV [Units] = KNm3 [value] = 0) [1] = = Array ([tagname] = kf_fic01342. TOTALIZERA_4.PV [Units] = KNm3 [value] = 0))
When using Array_key_exists ("value", $res), the statement returns false. I looked carefully to see why, $res array is a multidimensional array with a key name of two: 0, 1, no value, so returns FALSE.
Then how to judge the $res array, there is the value key ah? is a multidimensional array of what to write code?
------Solution--------------------
Array_key_exists ("value", $res [0])
------Solution--------------------
$arr = Array (' 0 ' = = Array (' tagname ' = ' kf_fic01341 '). TOTALIZERA_2.PV ', ' units ' = ' KNm3 ', ' value ' = 0, ' 1 ' = = Array (' tagname ' = ' kf_fic01342 '). TOTALIZERA_4.PV ', ' units ' = ' KNm3 ', ' value ' = 0));
function Check_index ($item, $key)
{
if (array_key_exists ("value", $item)) {
echo "This key value exists."
";
}else{
echo "does not have this key value."
";
}
}
Array_walk ($arr, ' Check_index ');