#28129 [WFx]: Overloading [] -operators would be very userful
| From: | helly@php.net | Date: | Sun, 25 Apr 2004 11:17:08 +0000 |
| Subject: | #28129 [WFx]: Overloading [] -operators would be very userful | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-58721@lists.php.net to get a copy of this message | ||
ID: 28129
Updated by: helly@php.net
Reported By: niz at sci dot fi
Status: Wont fix
Bug Type: Feature/Change Request
PHP Version: 5.0.0RC1
New Comment:
Also have a look at interface ArrayAccess
Previous Comments:
------------------------------------------------------------------------
[2004-04-23 22:58:02] derick@php.net
We're not going to overload any more operators, you can use SPL for
this anyway.
------------------------------------------------------------------------
[2004-04-23 19:27:55] niz at sci dot fi
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 this bug report at http://bugs.php.net/?id=28129&edit=1