The Array_search function in PHP finds the method of specifying the value of an array

Source: Internet
Author: User
This article mainly introduces PHP in the array to find the specified value of the method, the example analysis of PHP Array_search function to find the value of the array of the use of the skills, with a certain reference value, the need for friends can refer to the next

This example describes how PHP looks for a specified value in an array. Specific as follows:

PHP has two functions to determine whether the array contains the specified values, namely: Array_search ($value, $array) and In_array ($value, $array), Array_search can find out where the specified value appears in the array , the In_array function only determines if the specified value exists in the array and returns the BOOL value

<?php $array = Array ("Perl", "PHP", "Java", "PHP");p rint ("Search 1:". Array_search ("PHP", $array). " \ n ");p rint (" Search 2: ". Array_search (" Perl ", $array)." \ n ");p rint (" Search 3: ". Array_search (" C # ", $array)." \ n ");p rint (" \ n ");? >

The output is as follows

Search 1:1search 2:0search 3:

Summary : The above is the entire content of this article, I hope to be able to help you learn.

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.