|
|
Home Manual 11. API Reference mosObjectToArray |
| mosObjectToArray |
|
|
|
|
Last reviewed: 18 Nov 2005, Joomla 1.0.3 mosObjectToArrayCopy the contents of an object into an array. This function traverses each variable in an object and stores it in an array. Objects contained in objects are also converted into an array. Returns an array containing all the variables in the object if successful. If the parameter passed to it is not an object, it will return null. Syntaxarray mosObjectToArray ( object $obj )
Defined inlibraries/joomla/functions.php ExamplesExample: This function displays the contents of an object as an array. class exampleA { var $red; var $orange; var $yellow; } class exampleB { var $green; var $blue; var $violet; function exampleB() { $this->green = 5; $this->blue = 7; $this->violet = array('a', 'b', 'c'); } } function displayObject() { $obj1 = new ExampleA(); $obj1->red = 5; $obj1->orange = new ExampleB(); $obj1->yellow = "OK"; $array1 = mosObjectToArray( $obj1 ); foreach ($array1 as $k => $v) { echo "$k => $v <br />"; } } displayObject(); might produce: red => 5 orange => Array yellow => OK Please report any errors on this page to the Developer Documentation Forum. |
|
| Last Updated ( Tuesday, 03 January 2006 ) |
| < Prev | Next > |
|---|





