Home  >  Article  >  Backend Development  >  How to remove Array key value in PHP?

How to remove Array key value in PHP?

Guanhui
GuanhuiOriginal
2020-06-08 14:20:493029browse

How to remove Array key value in PHP?

#PHP How to remove Array key values?

In PHP, you can use the "array_keys()" function to remove the array key values. This function will return some or all of the key names in the array. The syntax is "array_keys(array)", Its parameter array represents the array whose key values ​​are to be removed. When using it, you only need to pass the array into the array.

Code example

<?php
$array = array(0 => 100, "color" => "red");
print_r(array_keys($array));
$array = array("blue", "red", "green", "blue", "blue");
print_r(array_keys($array, "blue"));
$array = array("color" => array("blue", "red", "green"),
               "size"  => array("small", "medium", "large"));
print_r(array_keys($array));
?>

Output:

Array
(
    [0] => 0
    [1] => color
)
Array
(
    [0] => 0
    [1] => 3
    [2] => 4
)
Array
(
    [0] => color
    [1] => size
)

Recommended tutorial: "PHP Tutorial

The above is the detailed content of How to remove Array key value in PHP?. 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
Previous article:PHP //Cannot commentNext article:PHP //Cannot comment