API16

JRegistry/loadArray: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:




{{subst:Description:JRegistry/loadArray}}
 


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




{{subst:SeeAlso:JRegistry/loadArray}}
 


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=loadArray
  category=loadArray
  category=JRegistry
  category=JRegistry
  category=CodeExample
  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