JRegistry/loadArray: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Load a associative array of values into the default namespace
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JRegistry/loadArray|E... |
m preparing for archive only |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
Load a associative array of values into the default namespace | Load a associative array of values into the default namespace | ||
===Syntax=== | ===Syntax=== | ||
| Line 57: | Line 55: | ||
</source> | </source> | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=loadArray | category=loadArray | ||
category=JRegistry | category=JRegistry | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 01:59, 25 March 2017
Description
Load a associative array of values into the default namespace
Syntax
loadArray($array, $namespace=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| $array | Associative array of value to load | |
| $namespace | null | The name of the namespace |
Returns
boolean True on success
Defined in
libraries/joomla/registry/registry.php
Importing
jimport( 'joomla.registry.registry' );
Source Body
public function loadArray($array, $namespace = null)
{
// If namespace is not set, get the default namespace
if ($namespace == null) {
$namespace = $this->_defaultNameSpace;
}
if (!isset($this->_registry[$namespace])) {
// If namespace does not exist, make it and load the data
$this->makeNameSpace($namespace);
}
// Load the variables into the registry's default namespace.
foreach ($array as $k => $v) {
$this->_registry[$namespace]['data']->$k = $v;
}
return true;
}
Examples
Code Examples