PHP array return entire section

39 views Asked by At

Hi I am trying to get everything in within the [] brackets. I have tried everything I could find but no luck

{
  "Items": [
    {
      "UID": "XXX-XXX",
      "Code": "USD",
      "CurrencyName": "US Dollar",
      "CurrencyRate": 0.71428000,
      "URI": "https://ar2.api.myob.com/accountright/XXX-XXX/GeneralLedger/Currency/XXX-XXX",
      "RowVersion": "-6496407278109851648"
    }
  ],
  "NextPageLink": null,
  "Count": 1
}

EDIT

My Code

   $getsbCurrencyDetailsclass = new myobsbfunctions($_SESSION['access_token'],api_key);
        $getsbCurrencyDetails = $getsbCurrencyDetailsclass->getResponsenew($cf_uri. "/GeneralLedger/Currency/?" .'$filter' ."=Code%20eq%20'{$docCurrencyType}'");

        
        $getsbCurrencyDetails = json_decode($getsbCurrencyDetails);

        $result=$getsbCurrencyDetails['Items'];
        //print("<pre>".print_r($result,true)."</pre>");
        echo $getsbCurrencyDetails
1

There are 1 answers

6
Eugen Rieck On

You need to convert the JSON into an array, then manipulate this array. Assuming the text is in $json:

$array=json_decode($json, true);
$result=$array['Items'];

EDIT

I forgot the second parameter to json_decode