PHP standard Library (SPL)-iterator-appenditerator and Arrayiterator detailed

Source: Internet
Author: User


Prototype:



Appenditerator extends Iteratoriterator implements Outeriterator {
* * method
/public __construct (void)
Publi c void Append (iterator $iterator) public
mixed current (void) public
void Getarrayiterator (void)
Publi C iterator Getinneriterator (void) public
int Getiteratorindex (void) public
scalar key (void) public
vo ID Next (void) public
void Rewind (void) public
bool Valid (void)/
* Inherited method/Public
Iteratoriter Ator::__construct (traversable $iterator) public
mixed iteratoriterator::current (void) public
traversable Iteratoriterator::getinneriterator (void) public
scalar iteratoriterator::key (void) public
void Iteratoriterator::next (void) public
void Iteratoriterator::rewind (void) public
bool Iteratoriterator:: Valid (void)
}

Example:


<?php 

    $array _a = new Arrayiterator (Array (' A ' => ' A1 ', ' B ' => ' B2 ', ' C ' => ' C3 '));
    $array _b = new Arrayiterator (Array (' d ' => ' D4 ', ' e ' => ' e5 ', ' F ' => ' F6 '));
    $array _c = new Regexiterator ($array _a, '/^[ac]/');
    $iterator = new Appenditerator ();
    Appends an iterator
    $iterator-> append ($array _a);
    $iterator-> Append ($array _b);
    for ($iterator-> Rewind (); $iterator-> valid (), $iterator-> Next ()) {
        echo $iterator-> current (). $itera Tor-> Key ();

    }
    foreach ($array _c as $current) {
        echo $current;
    }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.