How does PHP query specified elements in an array?

Source: Internet
Author: User
The array_search () function searches for a given value in the array and returns the key value. otherwise, false is returned. Before PHP4.2.0, the function returns null instead of false when it fails. The array_search () function searches for a given value in the array and returns the key value. otherwise, false is returned. Before PHP 4.2.0, the function returns null instead of false in case of failure.

Syntax format:

mixed aarray_search(mixed needle,array haystack [,bool strict])

The needle parameter specifies the value to be searched in the array; the haystack parameter specifies the array to be searched; the strict parameter is an optional parameter. if the value is true, the type of the given value is also checked in the array.

The following example uses the array function to update the values of elements in the array. the sample code is as follows:

 
 
 
Product Name Price Quantity Amount

The running result is:

The above is how PHP queries the details of the specified element in the array. For more information, see other related articles in the first PHP community!

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.