Re: re-keying an array

From: Date: Fri, 30 Apr 2004 02:06:55 +0000
Subject: Re: re-keying an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184993@lists.php.net to get a copy of this message
Justin French wrote:
been RTFMing for about 10 minutes, and can't find the function to re-key an array. In other words, I want an array of items to remain in their current order, but have the keys renumbered counting from zero. yes, I know it can be done with a foreach, but I was hoping for something native :) can anyone point me to the right page in the manual?
array_values() $newarray = array_values($old_array); Although this begs the question of why you'd need to "rekey" an array... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#184993) next »