10 May 2013

Convert Object array of class stdClass to array in PHP

While working with some API to fetch data from 3rd party website, you might have seen that most of these api send data in the form of std class object that is really frustrating for someone who is used to work with array, so with this small chunk of below mentioned code, you can easily convert a std class object to array form.

<?php
  $result = json_encode($result);
  $result = json_decode($result, true);
?>


Please post your comments if you find this useful

No comments:

Post a Comment