Trying to get property of non-object
//API REQUEST>>>>> ( 'criteria' => array ( 'additional' => array ( 'currency' => 'USD', 'dailyRate' => array ( 'maximum' => 10000, 'minimum' => 1, ), 'discountOnly' => false, 'language' => 'en-us', 'maxResult' => (int)$results, 'minimumReviewScore' => 0, 'minimumStarRating' => 0, 'occupancy' => array ( 'numberOfAdult' => (int)$adults, 'numberOfChildren' => 1, ), 'sortBy' => 'PriceAsc', ), 'checkInDate' => $in, 'checkOutDate' => $out, 'cityId' => (int)$hotel, ), ) //API RESPONSE>>>> { "results":[ { "hotelId":6501506, "hotelName":"Private room+bathroom (A2) / 10min walk MRT", "starRating":3.0, "reviewScore":8.6, "reviewCount":2, "currency":"USD", "dailyRate":9.91, "crossedOutRate":15.09, "discountPercentage":33.0, "imageURL":"http://pix6.agoda.net/hotelImages/6501506/0/29741738682c56e0c3ad1bf5f4a1f9b7.jpg?s=800x600", "landingURL":"https://www.agoda.com/partners/partnersearch.aspx?cid=1813200&hid=6501506¤cy=USD&checkin=2019-06-08&checkout=2019-06-12&NumberofAdults=2&NumberofChildren=1&Rooms=1&pcs=6", "includeBreakfast":false, "freeWifi":false, "latitude":13.8136554, "longitude":100.56936369999994 } <?php $result = (array)json_decode($result); echo "<pre>"; foreach($result as $row){ echo $row->hotelName."<br>"; } ?>