0

I have a numeric index array.

It can begin with any number, and then go on a hundred times.

I would rather have it ordered.

Example:

$myarray = array();

$myarray[500] = 2;
$myarray[501] = 3;

Should be:

$myarray[0] = 2;
$myarray[1] = 3;

I know I could do this with a foreach:

$i = 0;

foreach($myarray as $key => $value){
$myarray[$i] = $value;
$i++
}

Is there any function for this in PHP?

prgrm
  • 3,734
  • 14
  • 40
  • 80

1 Answers1

1

try with array_value

$myArray  = array_values($myArray);

Array_value will reset the key numerically and returns all the values from the array.

Narayan
  • 1,670
  • 1
  • 19
  • 37