Home > Article > Backend Development > How to remove the key value (value) of a one-dimensional array in php
In PHP, you can use the array_keys() function to remove the key value (value) of a one-dimensional array, leaving only the key name (key) of the array. The syntax format is "array_keys($array)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, each element of the array It is composed of key-value pairs, and the value of the corresponding key is accessed through the key name of the element.
提示:“索引”和“键名”指的是同一样东西,“索引”多指数组数字形式的下标。
Sometimes, we need to remove the key value (value) of a one-dimensional array and leave only the key name (key) of the array. How to do this?
At this point, you can use the array_keys() function.
array_key() function can obtain some or all key names in the array. The syntax format is as follows:
array_keys($array [, $search_value = null [, $strict = false]])
The parameter description is as follows:
===
. array_key() function will return the obtained array key name in the form of an array.
<?php header("Content-type:text/html;charset=utf-8"); $array = array( 'name' => 'PHP中文网', 'url' => 'https://www.php.cn/', 'title' => 'PHP教程', ); $key=array_keys($array); var_dump($key); ?>
As you can see, the key value (value) of the one-dimensional array is removed, and only the key name (key) of the one-dimensional array is returned.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to remove the key value (value) of a one-dimensional array in php. For more information, please follow other related articles on the PHP Chinese website!