PHP obtains the position of an element in the array and the array_keys function application _ php skills

Source: Internet
Author: User
There are many methods to obtain the position of an element in the array. among them, PHP itself has a built-in function array_keys (). the following code can print all the built-in functions of PHP, if you are interested, you can learn how to use the array_keys () function at the same time. as we all know, PHP has many built-in functions, this is also an important reason why PHP can greatly improve development efficiency. There are many ways to obtain the element location in the array. among them, PHP itself has built in a function array_keys (), the following code can print all PHP built-in functions:

The code is as follows:


Print_r (get_defined_functions ());
?>


The syntax of array_keys is as follows:

The code is as follows:


Array_keys (array, value, [strict])


When strict is set to true, the strict matching mode of data type verification is triggered. the default value is false. the following code shows a simple application of array_keys.

The code is as follows:


$ Test = array (10, 20, 30, "10", "20", "30 ");
Print_r (array_keys ($ test, "10", true); // exact match
// Output:
// Array ([0] => 3)
?>

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.