I used foreach to print all keys and values. "$devicename_key" is printing the key which is fine but "$devicetype_key" is not printing. I see the value of 129 exist in array.
I have array with id in one row and value in next, its coming from database and I was able to clean it up in something like this. If there is another way to do this, please feel free to tell me.
I am getting the key for 128 adding 1 to it and then printing the value of 128. 129 is not printing.
Key=0, Value=:128
Key=1, Value=:TCM-7811
Key=2, Value=:129
Key=3, Value=:2
Key=4, Value=:130
Key=5, Value=:3
foreach($extrafield_info as $x => $x_value) {
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
// device name 128
$deviceid_key = array_search('128', $extrafield_info);
//echo 'device id key is ' . $deviceid_key;
$devicename_key = $deviceid_key +1 ;
//echo 'device key is ' . $devicename_key;
// device type 129
if (array_key_exists('129', $extrafield_info)) {
$devicetype_key = array_search('129', $extrafield_info);
echo 'key is ' . $devicetype_key;
}