0

I have a returned variable $returned_variable that contains

{
    "companies": [{
                "id": "4127303000000527195",
                "company_name": "235 St Georges Landowning Trust & Australian City Properties Pty Ltd"
            }, {
                "id": "4127303000004495043",
                "company_name": "Bourke Junction No 1 Pty Ltd"
            }, {
                "id": "4127303000000527189",
                "company_name": "Brookfield Commercial Operations Pty Ltd"
            }, {
                "id": "4127303000000527063",
                "company_name": "GPT Property Management Pty Limited"
            }, {
                "id": "4127303000000527045",
                "company_name": "Investa Nominees (2) Pty Ltd & The Trustee for PSS/CSS A Property Trust"
            }, {
                "id": "4127303000012031116",
                "company_name": "Krys Co"
            }, {
                "id": "4127303000000527033",
                "company_name": "Lend Lease IMT (OITST ST) Pty Ltd as The Trustee for LL One"
            }
            ]
}

How can I parse it so I can use id and company_name as a separate variable ?

I've try json_decode but it doesnt work because its considering it as a whole text.

Ajith
  • 2,476
  • 2
  • 17
  • 38
Martney Acha
  • 2,802
  • 4
  • 33
  • 48
  • If "it doesnt work because its considering it as a whole text" was meant to allude to a concrete problem, then some sample code is necessary. See [mcve] – mario Nov 24 '20 at 05:00
  • reading between the lines it seems your after [array_column](https://www.php.net/manual/en/function.array-column.php).. https://3v4l.org/TXdkG – Lawrence Cherone Nov 24 '20 at 05:05

1 Answers1

1

Have you tried this ?

json_decode($returned_variable, true);