-1

I have got array with irregular number of keys, for example:

array: [ 0 => true, 2 => false, 3 => true, 8 => true ]

I want to see array like this:

array: [ 0 => true, 1 => false, 2 => true, 3 => true ]

How i can do this?

AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
syryls
  • 199
  • 1
  • 7

2 Answers2

0

You can use a builtin array_values PHP function, as shown below:

$arr = array_values($oldArray);
Dov Benyomin Sohacheski
  • 7,133
  • 7
  • 38
  • 64
-1

array_values does that :) http://php.net/manual/en/function.array-values.php

$fixedArray = array_values($arr);
clearshot66
  • 2,292
  • 1
  • 8
  • 17