Array ' find ' operation

Source: Internet
Author: User
1. Whether an element exists in the array:

Echo '
Array Operation 1:in_array ($value, $array, $type) ';//$type: Whether the value of $value is type-matched True/false, the default value is False $arr =array ("name" = "DOOR ",";(in_array ("+", $arr))? $v = "exists": $v = "does not exist"; echo "
". $v;

Code Run Result:

Operation of the array 1:in_array ($value, $array, $type) exists

2. Specify whether the key value exists in the array:

Echo '
The operation of the array 2:array_key_exists ($key, $array) ';//The key value of element 32 is 0, the lookup key value is "0", there is no strict type matching $arr=array ("name" = "DOOR", "+"); if (array _key_exists ("0", $arr)) {echo "
Exist ";}

Code Run Result:

Operation of the array 2:array_key_exists ($key, $array) exists

Summary: In_array and array_key_exists matching are case-sensitive.

The above introduces the array array ' find ' operation, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.