ID: 14763 Updated by: georg Reported By: [EMAIL PROTECTED] Old Status: Open Status: Bogus Bug Type: Feature/Change Request Operating System: PHP Version: 4.1.1 New Comment:
In first case, when you write to the array "[]" is a synonym for count($array) In second case, if you read from array "[]" should be (your suggestion/feature request) a synonym for count($array) - 1. Sorry, but this is not consistent. Previous Comments: ------------------------------------------------------------------------ [2001-12-30 09:42:34] [EMAIL PROTECTED] $b = $a[] would be $b = $a[count($a)-1], not $b = $a[count($a)] ------------------------------------------------------------------------ [2001-12-30 04:45:50] [EMAIL PROTECTED] There is no need to make an array '$a[]' readable. $a[] = "foo"; is short for $a[count($a)] = "foo"; if $a[] would be readable, result would be always NULL: $b = $a[] ( which would be the same as $a[count($a)]) ------------------------------------------------------------------------ [2001-12-30 04:29:01] [EMAIL PROTECTED] Currently in php, you can append to a variable by using the [] form: $a[] = 'a'; $a[] = 'b'; It would be great if you could also read an array in the same manner, ie: $lastadded = $a[]; which would be equivalent to $lastadded = $a[count($a)-1]; which is what you have to do today. /linus ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14763&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]