A class is an Object. We also name objects as instances. once we define a class and then make many objects that belong to it.
Following way to convert an object to array in PHP
we can use typecasting which is simply the explicit conversion of a data type. By using typecasting rules supported in PHP
The syntax for convert a PHP object to an array
$Array_var = (array) $Obj;
JSON encoded string is accepted by json_decode function and converts it into a PHP variable and on the other hand, JSON encoded string for a given value is returned by json_encode
The syntax for convert a PHP object to an array
$Array_var = json_decode(json_encode($obj), true);
$Array_var = array();
foreach ($obj as $key => $value)
{ $Array_var[] = $value;
}
We are Recommending you:
Step Out of Your Comfort Zone: 10 Powerful...
Is Mobile Reels Harming Our Children? Here's...
Simple body language tricks1. Stand with...
Best Free Websites to Learn CodingIf you...
The following steps help you to create a...
Whenever you visit a website or access any...
DIY: Make a Tote Bag from Old Clothes!Do you...
User experience (UX) plays a vital role in...
we provide custom social share links for...