Check if Value Exists in PHP Array

Hello friends,

Now i am explain how we check value exist in array. in_array() is the function in php to Check if a value exists in an array using PHP. Learn about Php

 

 

Parameters: The in_array() function accepts three parameters, out of which two are compulsory and other one is optional. All three parameters are described below:

val: This is a required parameter which specifies the element or value to be searched in the given array. This parameter can be of mixed type i.e, it can be of string type or integer type or any other type. If this parameter is of string type then the search will be performed in case-sensitive manner.

array_name: This is a required parameter and it specifies the array in which we want to search.

mode: This is an optional parameter and is of boolean type. This parameter specifies the mode in which we want to perform the search. If it is set to TRUE, then the in_array() function searches for the value with the same type of value as specified by val parameter. The default value of this parameter is FALSE.

Return Value: in_array() function returns a boolean value i.e, TRUE if the value val is found in the array otherwise it returns FALSE.

if else statement is similar to switch case statement in php. learn about switch case in php

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, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

− 2 = 1

%d bloggers like this: