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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.