20.6 C
New York
Saturday, August 13, 2022

How to convert Object into Array in PHP?

- Advertisement -





Whenever you need to convert object to array in your php project then you can do that using (array). It is a pretty simple example to convert php object into array that way you can use array. So, let’s see the following example.

Example:

$myObject = new MyClass;

$myObject->id = 100;

$myObject->title = "posts";

$myObject->description = "this is posts";

$newArray = (array) $myObject;

print_r($newArray);

- Advertisement -

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles