Given an array and a specific value, we have to determine whether the array contains that value or not. So there is two popular way to determine that the specific value is in the array or not. One procedure is using by loop and other one is in_array() function. By using loop to get the specific value present or not is time-consuming compared to in_array() function so here we will skip the loop one and use the in_array() function.
Below programs illustrate how to determine if an array contains a specific value:
Your element founded
Program 2: In this example the in_array function perform in strict mode, it will also check the type of array elements.
not found found found
In the above example, the array contains string “gfg” and two numbers 1 and 17. The if statement calls in_array() function which checks if the given item as the parameter is present in the given array or not. If the function returns true, the if statement is executed.
- How to determine length or size of an Array in Java?
- How to determine active route in AngularJS ?
- Determine the first and last iteration in a foreach loop in PHP?
- How to determine the content of HTML elements overflow or not ?
- How to determine the direction of a jQuery scroll event?
- How to position a div at specific coordinates ?
- Domain Specific Tools
- How to adjust CSS for specific zoom level?
- How to find element with specific ID using jQuery ?
- How to get specific number of child elements using CSS?
- How to get text of specific option tag using jQuery?
- How to select all elements that contains some specific CSS property using jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.