Today now in this post i will show you how to convert an object into array in php. Whenever we need to convert an object to array in our php project then we can do this by using (array). So It is a very simple example to convert php object into an array that way we can do this by use array.
So, let’s see that on the following example.
$myObject = new MyClass; $myObject->id = 100; $myObject->title = "posts"; $myObject->description = "this is posts"; $newArray = (array) $myObject; print_r($newArray);
Thanks for read. I hope it help you. For more you can follow us on facebook.