The fastest way to replace associative array keys with numeric keys

I have an array:

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

I would like to replace it (as quickly as possible using a simple built-in function) as follows:

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

Is it possible to use any built-in php array functions?

+3
source share
3 answers

check array_values

$new_array=array_values($array);
print_r($new_array);
+20
source
$arr = array(
             'something'=>'something',
             'something'=>'something'
             );

$new_arr = array();
$new_arr = array_values(arr);

    print_r($new_arr);
+1
source
$arr = array(
    'something'=>'something',
    'something'=>'something'
);

sort($arr);

print_r($arr);
-1
source

All Articles