While developing web applications, in some cases we have to check for array value existence in that situation we can easily check for the value using PHP’s built-in function in_array()
. Here is the code
1 2 3 4 5 6 7 |
<?php // names array with 4 members $names = array('arjun','naveen','Raj ','Mahesh '); if(in_array("arjun",$names)) { // do something } ?> |
Used PHP functions
in_array() — Checks if a specified value exists in an array
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.
Subscribe
Login
0 Comments