Home >Backend Development >PHP Problem >How to remove the key value of an array in php
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 )".
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)
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));//严格模式 ?>
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!