$object -> $array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

$object -> $array

Post by bokehman »

How do I turn an object into an array?
or
How do I make an array that contains the contents of an object?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

you need to read up on what an object is.
http://php.net/oop
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

typecast it
http://us3.php.net/language.types.type-juggling

Code: Select all

<?php
$object = new MyObject;

$object_array = (array) $object;
?>
Post Reply