top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of in_array() function in php ?

+3 votes
407 views
What is the use of in_array() function in php ?
posted Mar 11, 2016 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The in_array() function searches an array for a specific value.

Syntax

in_array(search,array,type)

Example

<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");

if (in_array("Glenn", $people))
  {
  echo "Match found";
  }
else
  {
  echo "Match not found";
  }
?>
answer Mar 11, 2016 by Ashish Kumar Khanna
...