开发者

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) t开发者_如何学Pythono be like this:

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

Possible using any built-in php-array functions?


check out array_values

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


$arr = array(
             'something'=>'something',
             'something'=>'something'
             );

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

    print_r($new_arr);


$arr = array(
    'something'=>'something',
    'something'=>'something'
);

sort($arr);

print_r($arr);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜