[ create a new paste ] login | about

Link: http://codepad.org/C0DdlEp8    [ raw code | output | fork | 6 comments ]

PHP, pasted on Mar 19:
<?php

class MyArrayIterator extends ArrayIterator
{
	public function __construct ($array)
    {
        echo __METHOD__, PHP_EOL;
        parent::__construct($array);
    }

	public function count ()
    {
        echo __METHOD__, PHP_EOL;
        return parent::count();
    }

	public function current()
    {
        echo __METHOD__, PHP_EOL;
        return parent::current();
    }

	public function key ()
    {
        echo __METHOD__, PHP_EOL;
        return parent::key();
    }

	public function next ()
    {
        echo __METHOD__, PHP_EOL;
        return parent::next();
    }

	public function rewind ()
    {
        echo __METHOD__, PHP_EOL;
        return parent::rewind();
    }

	public function valid ()
    {
        echo __METHOD__, PHP_EOL;
        return parent::valid();
    }
}
foreach (new MyArrayIterator(range(1,3)) as $k => $v) {
    echo "$k => $v", PHP_EOL;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
MyArrayIterator::__construct
MyArrayIterator::rewind
MyArrayIterator::valid
MyArrayIterator::current
MyArrayIterator::key
0 => 1
MyArrayIterator::next
MyArrayIterator::valid
MyArrayIterator::current
MyArrayIterator::key
1 => 2
MyArrayIterator::next
MyArrayIterator::valid
MyArrayIterator::current
MyArrayIterator::key
2 => 3
MyArrayIterator::next
MyArrayIterator::valid


Create a new paste based on this one


Comments:
posted by dsfdskl on Jun 23
Welcome
reply
posted by dsfdskl on Jun 23
Welcome to rest
reply
posted by dsfdskl on Jun 23
it is very worst code for performance
reply
posted by dsfdskl on Jun 23
-:)
reply
posted by dsfdskl on Jun 23
Hey chumma sonnen super da machi
reply
posted by dsfdskl on Jun 23
Nice logic
reply