From:             niz at sci dot fi
Operating system: 
PHP version:      5.0.0RC1
PHP Bug Type:     Feature/Change Request
Bug description:  Overloading [] -operators would be very userful

Description:
------------
I was developing own array class for php5 and result was not very usable
because I can't overload [] -operator..
It's good that iteration is now in php5 but better overloading support is
needed.

It could work something like this:

class xArray {
    private $data = array(0 => "first", 1 => "second");
    function __index($key) {
        return $this->data[$key]
    }
}

$test = new xArray();
print($test[0]); // would print "first"



-- 
Edit bug report at http://bugs.php.net/?id=28129&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28129&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28129&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28129&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28129&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28129&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28129&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28129&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28129&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28129&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28129&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28129&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28129&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28129&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28129&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28129&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28129&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28129&r=float

Reply via email to