Difference between revisions of "JArrayHelper/fromObject"
From Joomla! Documentation
< API16:JArrayHelper
(New page: ===Description===
Utility function to map an object to an array
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JArrayHelper/fromObject|Edit Descript...) |
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>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 73: | Line 73: | ||
<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 88: | Line 88: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Revision as of 21:49, 12 May 2013
The "API16" 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 object to an array
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
static fromObject($p_obj, $recurse=true, $regex=null)
Parameter Name | Default Value | Description |
---|---|---|
$p_obj | The source object | |
$recurse | true | True to recurve through multi-level objects |
$regex | null | An optional regular expression to match on field names |
Returns[edit]
array The array mapped from the given object
Defined in[edit]
libraries/joomla/utilities/arrayhelper.php
Importing[edit]
jimport( 'joomla.utilities.arrayhelper' );
Source Body[edit]
static function fromObject($p_obj, $recurse = true, $regex = null)
{
$result = null;
if (is_object($p_obj))
{
$result = array();
foreach (get_object_vars($p_obj) as $k => $v)
{
if ($regex)
{
if (!preg_match($regex, $k))
{
continue;
}
}
if (is_object($v))
{
if ($recurse)
{
$result[$k] = JArrayHelper::fromObject($v, $recurse, $regex);
}
}
else
{
$result[$k] = $v;
}
}
}
return $result;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />