Tools, FAQ, Tutorials:
Finding a Given Value in an Array in PHP
How To Find a Specific Value in an Array in PHP?
✍: FYIcenter.com
There are two functions can be used to test if a value is defined in an array or not:
Here is a PHP script on how to use array_search():
<?php $array = array("Perl", "PHP", "Java", "PHP"); print("Search 1: ".array_search("PHP",$array)."\n"); print("Search 2: ".array_search("Perl",$array)."\n"); print("Search 3: ".array_search("C#",$array)."\n"); print("\n"); ?>
This script will print:
Search 1: 1 Search 2: 0 Search 3:
⇒ Retrieving All Keys from an Array in PHP
⇐ Verifying If a Key Exists in an Array in PHP
2017-01-21, 1740🔥, 0💬
Popular Posts:
What is the "__init__()" class method? The "__init__()" class method is a special method that will b...
Where to find tutorials on Using Azure API Management Publisher Dashboard? Here is a list of tutoria...
How to login to the Developer Portal internally by you as the publisher? Normally, the Developer Por...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...