API16

JArrayHelper/toObject: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
No edit summary
m removing red link to edit, no existant pages
Line 3: Line 3:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JArrayHelper/toObject|Edit Descripton]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>


{{Description:JArrayHelper/toObject}}
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 56: Line 56:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JArrayHelper/toObject|Edit See Also]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>
{{SeeAlso:JArrayHelper/toObject}}
<! removed transcluded page call, red link never existed >


===Examples===
===Examples===
Line 71: Line 71:
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Revision as of 02:50, 13 May 2013

Description

Utility function to map an array to a stdClass object.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

static toObject(&$array, $class= 'stdClass')
Parameter Name Default Value Description
&$array $array The array to map.
$class 'stdClass' $calss Name of the class to create

Returns

object The object mapped from the given array

Defined in

libraries/joomla/utilities/arrayhelper.php

Importing

jimport( 'joomla.utilities.arrayhelper' );

Source Body

static function toObject(&$array, $class = 'stdClass')
{
        $obj = null;
        if (is_array($array))
        {
                $obj = new $class();
                foreach ($array as $k => $v)
                {
                        if (is_array($v)) {
                                $obj->$k = JArrayHelper::toObject($v, $class);
                        } else {
                                $obj->$k = $v;
                        }
                }
        }
        return $obj;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />