Foreach inside of Foreach?

I have an API that returns a JSON Array of data relating to real estate listings.

Inside that array is another array containing the images of the house.

What I need to do is loop through the “properties” array, import some data from it into the local database, then import the images from the “images” array into local storage.

The input JSON looks like this:

            "": "Property(12345)",
            "City": "CoosBay",
            "ListPrice": 595000.0,
            "ListingKey": "1234",
            "PropertySubType": "Commercial",
            "PropertyType": "CommercialSale",
            "YearBuilt": 1951,
            "Media": [
                    "MediaURL": "",
                    "ModificationTimestamp": "2004-09-22T11:38:25-07:00",

Is it best to just do something like:

foreach($properties as $property){
 /*import the data values*/
  foreach($property->Media as $image){
 /*Import the image*/

Yes, that would be the way to go :+1:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.