foreach($jsonmediationinfo as $value1) {
echo $value1['mstatus'];
print_r($jsonmediationinfo);
}
Output:
1Array ( [0] => Array ( [mstatus] => 1 [mhearingnum] => first [mminutes] => adakjaflafjlarjkelfkalfkd;la ) [1] => Array ( [mhearingnum] => second [mminutes] => ) [2] => Array ( [mhearingnum] => third [mminutes] => ) )
Undefined index: mstatus in ... on line 265 line 265 is line echo $value1['mstatus'];
This is my php server side code.This used to saved data into database but i am getting undefined index:mstatus in line 265. But in the print_r the index mstatus clearly exists. Also if I check in database when I update the data the values changes to correct value. In this example the value is changed to 1.
What is the problem in this line of code. Any suggestion is appreciated
The array you're looping looks like this:
Only the sub array at the first index contains
mstatus, so on the second iteration of the loop it throws the exception. It's best to check ifmstatusis present usingisset($value1['mstatus']).In a real life scenario you could handle your status like this: