What is the usage of the in_array function in PHP?

The in_array() function in PHP is used to check if a specified value exists in an array. Its syntax is:

bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )

Parameter Description:

  1. $needle: the value to be searched for
  2. The haystack is an array that contains the values to be searched.
  3. $strict: an optional parameter that, when set to true, makes the function also check types during search.

The function returns a boolean value, returning true if the specified value is found in the array, and false otherwise.

Leave a Reply 0

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


广告
Closing in 10 seconds
bannerAds