Purpose:
$arr = array('key1'=>'value1','key2'=>'value2','key3'=>'value3')
Convert the above array into the following format:
$arr = array('value1','value2','value3')
The solution is as follows:
You can use array_values( ) method to achieve.
array_values() function returns an array containing all the values in the array.
Tip: The returned array will use numeric keys, starting from 0 and increasing by 1.
The specific code is as follows:
$arr = array('key1'=>'value1','key2'=>'value2','key3'=>'value3'); $arr2 = array_values($arr); print_r($arr2);
For more related tutorials, please visit php Chinese website.
The above is the detailed content of How to remove array subscript in php. For more information, please follow other related articles on the PHP Chinese website!