$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?
Reply to discussion (solution)
Array_key_exists ("value", $res [0])
$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_ke Y_exists ("value", $item)) { echo "exists this key value.")
"; } else{ echo "No this key value". "
"; }} Array_walk ($arr, ' Check_index ');
$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 my () { $arr =func_get_args (); foreach ($arr as $k = + $v) { $item =array_key_exists (' value ', $v); if ($item) { echo ' exists '; break; } else{ ' does not exist '; }} } Call_user_func_array (' my ', $arr);
Moderator method The simplest, thank you ~ ~