Jump to content

is there a way to reset the array keys? to 0,1,2,3,...


tastro

Recommended Posts

is there a way to reset the array keys? to 0,1,2,3,...

 

also for example that i have something like this:

 

$array['dog']='dog';

$array['mouse']='mouse';

$array['cat']='cat';

 

and i want it like this:

 

$array[0]='dog';

$array[1]='mouse';

$array[2]='cat';

 

is there a function for that already in php?

is there a way to reset the array keys? to 0,1,2,3,...

 

Reset them to what? Do you have an array with holes in it's keys?

 

also for example that i have something like this:

 

$array['dog']='dog';

$array['mouse']='mouse';

$array['cat']='cat';

 

and i want it like this:

 

$array[0]='dog';

$array[1]='mouse';

$array[2]='cat';

 

is there a function for that already in php?

 

array_values.

 

It's probably best to refer to the manual for these types of questions rather than posting here and waiting for a reply. there is an entire section on the array functions: http://php.net/manual/en/ref.array.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.