-2

Is there any function or something to reset the keys of an array?

I have this array:

Array ( [4] => 8 [6] => 3 [7] => 2 [8] => 7 ) 

I need it to be like this:

Array ( [0] => 8 [1] => 3 [2] => 2 [3] => 7 ) 

I've tried some for cycles and stuff like that to replace the keys but there's probably something out there that does this automatically and instantly.

Simolius
  • 77
  • 9

1 Answers1

2

In this case, you can just use

$yourarray = Array ( [4] => 8 [6] => 3 [7] => 2 [8] => 7 );
$desired_array = array_values($yourarray);
nicael
  • 18,550
  • 13
  • 57
  • 90