Home >Backend Development >PHP Problem >How to remove key from php array

How to remove key from php array

王林
王林Original
2020-07-31 13:38:034013browse

The method to remove the key from the php array is: you can remove the key through the array_values() function, the usage method is as follows: [array_values($a)]. The array_values() 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.

How to remove key from php array

Function introduction:

(Recommended tutorial: php graphic tutorial)

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.

(Video tutorial recommendation: php video tutorial)

Function syntax:

array_values(array)

Code implementation:

<?php
$a=array("Name"=>"Peter","Age"=>"41","Country"=>"USA");
print_r(array_values($a));
?>

The above is the detailed content of How to remove key from php array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn