PHP array introductory tutorial array_keys() function

WBOY
Release: 2016-07-25 08:57:52
Original
1024 people have browsed it
This article introduces the usage of the array_keys() function in PHP arrays. Friends in need can refer to it.

In php array functions, array_keys() function returns an array containing all the keys found in the searched array.

The form is as follows: array array_keys(array array[,mixed search_value])

If the optional parameter search_value is included, only keys matching that value will be returned.

Example that will output all arrays found in the $fruit array:

<?php
$fruits["apple"] = "red";  
$fruits["banana"] = "yellow";  
$fruits["watermelon"]="green";  
$keys = array_keys($fruits);  
print_r($keys);  //by bbs.it-home.org
  
//Array ( [0] => apple [1] => banana [2] => watermelon )
?>
Copy after login


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!