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, ∼3103🔥, 0💬
Popular Posts:
How To Change Text Fonts for Some Parts of a Paragraph? If you want to change text fonts or colors f...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...
How To Merge Cells in a Column? If you want to merge multiple cells vertically in a row, you need to...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...