Home > Article > Backend Development > How to delete the key value of an array in php
The method to delete the key value of an array in php is: you can use the array_values() function to achieve this. This function returns an array containing all the values in the array. The returned array will use numeric keys, starting from 0 and increasing by 1. Function syntax: [array_values(array)].
#If you want to delete the key value of the array, you can use the array_values() function to achieve this. Let's introduce this function below.
(Recommended tutorial: php tutorial)
Function introduction:
array_values() function returns an array containing all the values in the array.
Note: The returned array will use numeric keys, starting from 0 and increasing by 1.
Syntax:
array_values(array)
Parameter description:
<?php $arr = array('key1'=>'value1','key2'=>'value2','key3'=>'value3'); $arr2 = array_values($arr); print_r($arr2); ?>Output result:
array('0'=>'value1',‘1'=>'value2','2'=>'value3');
The above is the detailed content of How to delete the key value of an array in php. For more information, please follow other related articles on the PHP Chinese website!