I want to return an array containing the keys:
<?php
if(isset($values[0]->Content)):
$jarray= json_decode($values[0]->Content);
print_r(array_keys($jarray));
exit;
endif;
?>
Output of $jarray:
stdClass Object
(
[_token] => QjyTAyDDUeadYvO0qj0gAZyK7OVyudSsY7Sq8Hhp
[datefrom] => 2017-07-07
[dateto] => 2017-07-31
[Productivity] => test1
[Productivityrating] => 2
[Technical_Skills] => test2
[Technical_Skillsrating] => 3
[Work_Consistency] => test3
[Work_Consistencyrating] => 4
[Presentation_skills] => test4
[Presentation_skillsrating] => 5
[test] => test5
[testrating] => 3
[cycle_id] => 1
[save] => proceed
)
I want to return an array containing the keys so i tried
array_keys($jarray)
but it gives an error like
array_keys() expects parameter 1 to be array, object given (View: my path)
Expected output:
Array
(
[0] =>_token
[1] => datefrom
[2] =>_dateto
[3] => Productivity
[4] =>Productivityrating
[5] => Work_Consistency
[6] =>_Work_Consistencyrating
)etc
Any help would be appreciated.
$jarrayis an object$jarray= (array) $jarray;, typecasting object to array