Difference between revisions of "JArrayHelper/toObject"
From Joomla! Documentation
< API15:JArrayHelper
(New page: ===Description===
Utility function to map an array to a stdClass object.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JArrayHelper/toObject|Edit D...) |
m (removing red link to edit, no existant pages) |
||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 17: | Line 17: | ||
!Description | !Description | ||
|- | |- | ||
− | | | + | | &$array |
| | | | ||
| $array The array to map. | | $array The array to map. | ||
Line 56: | Line 56: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 71: | Line 71: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API15]] |
Revision as of 08:43, 12 May 2013
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
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[edit]
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[edit]
object The object mapped from the given array
Defined in[edit]
libraries/joomla/utilities/arrayhelper.php
Importing[edit]
jimport( 'joomla.utilities.arrayhelper' );
Source Body[edit]
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[edit]
<CodeExamplesForm />