note 23886 added to function.array-push

From: Date: Tue, 30 Jul 2002 23:23:10 +0000
Subject: note 23886 added to function.array-push
Groups: php.notes 
Request: Send a blank email to php-notes+get-34024@lists.php.net to get a copy of this message
The problem is that you might want things added to the array in order. $array['key'] = 'value' doesn't have the same ordering semantics as array_push($array, 'key' => 'value') would. ksort() implies that PHP understands ordered 'key' => 'value' pairs in arrays, but there doesn't seem to be a way to tell it to add one to the end of an array. That being said, it seems that adding new keys to an array always get pushed to the end of the array anyway, it just feels extremely dangerous writing code that relies on that as it's non-obvious, and what if it changes in the future? It'd be nice if array_push supported '=>' notation. -- http://www.php.net/manual/en/function.array-push.php http://master.php.net/manage/user-notes.php?action=edit+23886 http://master.php.net/manage/user-notes.php?action=delete+23886 http://master.php.net/manage/user-notes.php?action=reject+23886

« previous php.notes (#34024) next »