API16

JSimpleXMLElement/removeChild: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JSimpleXML...
 
m preparing for archive only
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JSimpleXMLElement/removeChild|Edit Descripton]]<nowiki>]</nowiki>
</span>
{{Description:JSimpleXMLElement/removeChild}}
===Syntax===
===Syntax===
<source lang="php">removeChild(&$child)</source>
<source lang="php">removeChild(&$child)</source>
Line 15: Line 8:
!Description
!Description
|-
|-
|  
| &$child
|  
|  
|   
|   
Line 48: Line 41:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JSimpleXMLElement/removeChild|Edit See Also]]<nowiki>]</nowiki>
 
</span>
{{SeeAlso:JSimpleXMLElement/removeChild}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=removeChild
  category=removeChild
  category=JSimpleXMLElement
  category=JSimpleXMLElement
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:06, 25 March 2017

Syntax

removeChild(&$child)
Parameter Name Default Value Description
&$child

Defined in

libraries/joomla/utilities/simplexml.php

Importing

jimport( 'joomla.utilities.simplexml' );

Source Body

function removeChild(&$child)
{
        $name = $child->name();
        for ($i=0,$n=count($this->_children);$i<$n;$i++)
        {
                if ($this->_children[$i] == $child) {
                        unset($this->_children[$i]);
                }
        }
        for ($i=0,$n=count($this->{$name});$i<$n;$i++)
        {
                if ($this->{$name}[$i] == $child) {
                        unset($this->{$name}[$i]);
                }
        }
        $this->_children = array_values($this->_children);
        $this->{$name} = array_values($this->{$name});
        unset($child);
}



Examples

Code Examples