How to remove Array key value in PHP?

Guanhui
Release: 2023-03-01 13:12:02
Original
3009 people have browsed it

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));
?>
Copy after login

Output:

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

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!