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, 1765🔥, 0💬
Popular Posts:
How to use the RSS Online Validator at w3.org? You can follow this tutorial to learn how to use the ...
How to use the "forward-request" Policy Statement to call the backend service for an Azure API servi...
How To Open Standard Output as a File Handle in PHP? If you want to open the standard output as a fi...
How to use the XML to JSON Conversion Tool at freeformatter.com? If you want to try the XML to JSON ...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...