I have this array that I read (using curl) in PHP it returns a string that looks like a json so I convert it into a real json.
But what ever I do to read it, does not work:
what am I doing wrong and how can I reach those values?
This is the result that I get:
Array
(
[results] => Array
(
[1] => Array
(
[pack_id] => HUJoUJKK673ED
[imre] => 87687548574
[imrd] => 87457654764
[cell_id] => 775443
[firm_vrs] => 2
[gg_yr] => 2017
[gg_mn] => 3
[gg_dy] => 20
[gg_hr] => 15
This is my code
<?php
$url = $_GET["url"];
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
$returnVal = curl_exec($curlSession);
curl_close($curlSession);
//converting the retreived "json lookalike text" in to a json:
$decodedText = html_entity_decode($returnVal);
$myArray = json_decode($decodedText, true);
//this DOES work and shows the json as an array, as described above.
echo "<pre>";
print_r($myArray);
echo "</pre>";
//BUT non of the following lines work:
$echo = sizeof($myArray->results);
echo "<br />".$myArray->results[1]->imre;
echo "<br />".sizeof($myArray);
echo "<br />".sizeof($myArray->results);
echo "<br />".sizeof($myArray->results[1]);
echo "<br />".sizeof($myArray[1][1]);
echo "<br />".sizeof($myArray[0]);
echo "<br />".sizeof($myArray[0]->results);
echo "<br />".sizeof($myArray->imre);
echo "<br />".sizeof($myArray[0]->results);
echo "<br />".$myArray->results['1']->imre;
echo "<br />".$myArray[0]->results[1]->imre;
echo "<br />".$myArray->results[1]->imre;
echo "<br />".sizeof($myArray->results[1]);
?>