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!