Discard keys even numerics

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Discard keys even numerics

Post by Ollie Saunders »

I'm having a blonde day today. I always thought array_values did this but obviously not. Is there a single function call to discard all the keys and start index again from zero. What I want is this:

Code: Select all

$array = array(1 => 'a', 50 => 'b');
$this->assertIdentical(someFunc($array), array(0 => 'a', 1 => 'b'));
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

OK..I need to trust my myself more and my code less :)
Turns out a bit of code supposed to be calling array_values actually wasn't.
Post Reply