downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

CachingIterator> <ArrayIterator::unserialize
[edit] Last updated: Fri, 25 May 2012

view this page in

ArrayIterator::valid

(PHP 5 >= 5.0.0)

ArrayIterator::validComprueba si un array contiene más entradas

Descripción

public bool ArrayIterator::valid ( void )

Comprueba si un array contiene más entradas.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

No devuelve ningún valor.

Ejemplos

Ejemplo #1 Ejemplo de ArrayIterator::valid()

<?php
$array 
= array('1' => 'uno');

$arrayobject = new ArrayObject($array);
$iterator $arrayobject->getIterator();

var_dump($iterator->valid()); //bool(true)

$iterator->next(); // avanza al siguiente ítem

//bool(false) porque sólo hay un elemento array
var_dump($iterator->valid());
?>



add a note add a note User Contributed Notes ArrayIterator::valid
kaigillmann at gmxpro dot net 11-Nov-2005 01:55
Sometimes you need to search through the array.
Here is my object-orientated Version:

<?php
class MyArrayIterator extends ArrayIterator
{
    public function
available($value)
    {
        if (
in_array($value, (array)$this))
            return
true;
        else
            return
false;
    }
   
    public function
search($value)
    {
        foreach((array)
$this as $Key => $values)
        {
            if (
$values == $value)
                return
$Key;
        }
        return
false;
    }
}
?>

 
show source | credits | sitemap | contact | advertising | mirror sites