PHP 8.6.0 Beta 1 is available for testing

SimpleXMLElement::rewind

(PHP 8)

SimpleXMLElement::rewindReemplaza el puntero al inicio

Descripción

public function SimpleXMLElement::rewind(): void
Advertencia

Antes de PHP 8.0, SimpleXMLElement::rewind() solo estaba declarada en la subclase SimpleXMLIterator.

Este método reinicia el iterador SimpleXMLElement al primer elemento.

Nota: A partir de PHP 8.4.0, llamar a los métodos get (como SimpleXMLElement::asXML() o SimpleXMLElement::getName()) o convertir un SimpleXMLElement a string ya no rebobina implícitamente el iterador. Cuando sea necesario, el iterador debe ser rebobinado explícitamente llamando a este método.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

No se retorna ningún valor.

Ejemplos

Ejemplo #1 Retorno al primer elemento

<?php
$xmlElement = new SimpleXMLElement('<books><book>PHP Basics</book><book>XML Basics</book></books>');
$xmlElement->rewind();

var_dump($xmlElement->current());
?>

El ejemplo anterior mostrará:

object(SimpleXMLElement)#2 (1) {
  [0]=>
  string(10) "PHP Basics"
}

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top