Home > Backend Development > PHP Problem > How to remove the key value of an array in php

How to remove the key value of an array in php

青灯夜游
Release: 2023-03-15 14:04:02
Original
1424 people have browsed it

In PHP, you can use the array_keys() function to remove the key value of the array. This function can only obtain and return some or all key names of the array. The syntax "array_keys($array,$value,$strict )".

How to remove the key value of an array in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In PHP, you can use the array_keys() function to remove the key value of the array.

The array_keys() function can get some or all key names in the array.

Syntax:

array_keys($array,$value,$strict)
Copy after login

Parameter description is as follows:

  • $array: required parameter, which is the array to be operated;

  • $value: Optional parameter. If the parameter is empty, the function will return all the key names in the array. If this parameter is specified, the function will only return the key name with the value $value;

  • $strict: Optional parameter to determine whether to use strict mode when searching. $strict defaults to false, which is non-strict mode. Only types are compared when searching, not types. , if $strict is set to true, that is, strict mode, the value and type are compared at the same time during search, which is equivalent to ===.

array_key() function will return the obtained array key name in the form of an array.

Example:

<?php
header("Content-type:text/html;charset=utf-8");
$arr=array("Volvo"=>"XC90","BMW"=>"X5","Toyota"=>"Highlander","id"=>"123");
var_dump($arr);
var_dump(array_keys($arr));
var_dump(array_keys($arr,123));//非严格模式
var_dump(array_keys($arr,123,true));//严格模式
?>
Copy after login

How to remove the key value of an array in php

Recommended learning: "PHP Video Tutorial"

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

Related labels:
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