Bug #14763 Updated: Make [] of arrays readable

From: Date: Sun, 30 Dec 2001 14:42:35 +0000
Subject: Bug #14763 Updated: Make [] of arrays readable
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-75355@lists.php.net to get a copy of this message
ID: 14763 User updated by: linus@mccabe.nu Reported By: linus@mccabe.nu Status: Open Bug Type: Feature/Change Request Operating System: PHP Version: 4.1.1 New Comment: $b = $a[] would be $b = $a[count($a)-1], not $b = $a[count($a)] Previous Comments: ------------------------------------------------------------------------ [2001-12-30 04:45:50] georg@php.net 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] linus@mccabe.nu 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

« previous php.dev (#75355) next »