I am getting below output from a string, that I want to decode into a simple array so that I could use those value to process. web-service used below function to return response
echo(var_export($response));
Response
stdClass::__set_state(array(
'criteriaKeyResultsMap' =>
stdClass::__set_state(array(
'477270310' => true,
'528726710' => false,
'517907210' => true,
'497709910' => true,
'253529610' => false,
'529845410' => true,
'519674810' => false,
'517587110' => false,
'477270610' => true,
'260901310' => false,
'260901610' => false,
'529845110' => true,
)),
))
I am trying with json_decode() but it gives same result.
asked Apr 12, 2016 at 4:32
Praveen D
2,3773 gold badges33 silver badges44 bronze badges
-
How are you getting the string? It seems like there might be another problem here preventing an easier way of accessing the data.Scopey– Scopey2016年04月12日 04:36:41 +00:00Commented Apr 12, 2016 at 4:36
-
API used echo(var_export($response)); to return resultPraveen D– Praveen D2016年04月12日 05:00:16 +00:00Commented Apr 12, 2016 at 5:00
2 Answers 2
The best fix will be to update your API (if you have control of the source) to use json_encode instead of var_export before it does an echo.
Parsing the output of var_export is possible, but a lot more complex, resource intensive and prone to breakage in the future.
answered Apr 12, 2016 at 5:22
Scopey
6,3291 gold badge24 silver badges34 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Praveen D
I don't have control to change in API.
lang-php