Search code examples
phparrayskeyassociative-array

Quickest way to replace associative array keys with numerical keys


I have an array:

array('something' => 'like this', 'something' => 'like this', 'something' => 'like this');

I would like to replace it (quickly as possible, using a simple inline function) to be like this:

array(0 => 'like this', 1 => 'like this', 2 => 'like this');

Possible using any built-in php-array functions?


Solution

  • check out array_values

    $new_array=array_values($array);
    print_r($new_array);