Home> php教程> php手册> body text

Commonly used array functions in php (4) (whether there is a certain key name or index in the array)

WBOY
Release: 2016-10-28 15:03:32
Original
1148 people have browsed it
/***********array_key_exists(检查键名或索引是否在数组中)*****************/ $arr1 = array('name' => 'Sheldon', 'age' => 30, 'address' => 'Carlifornia'); if (array_key_exists('name', $arr1)) { echo 'the name element is in the array.'; } else { echo 'name elment not exist.'; }
Copy after login

Check if there is a key named 'name' in $arr1.

Also check the numerical index.

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 Recommendations
    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!