PHP in_array() ফাংশন

উদাহরণ

একটি আদান-প্রদান এক্সচেঞ্জ প্রক্রিয়ায় "Glenn" মান অনুসন্ধান করুন এবং কোনো টেক্সট প্রদর্শন করুন:

<?php
$people = array("Bill", "Steve", "Mark", "David");
if (in_array("Mark", $people))
  {
  echo "মিলন পাওয়া গেছে";
  }
else
  {
  echo "মিলন পাওয়া যায়নি";
  }
?>

Run Example

সংজ্ঞা ও ব্যবহার

in_array() ফাংশন একটি আদান-প্রদান এক্সচেঞ্জ প্রক্রিয়ায় নির্দিষ্ট মান কোনো মান সহযোগী কোনো মান থাকে কিনা অনুসন্ধান করে。

Note:If search The parameter is a string and type If the parameter is set to TRUE, the search is case-sensitive.

Syntax

in_array(search,array,type)
Parameter Description
search Required. Specifies the value to be searched in the array.
array Required. Specifies the array to be searched.
type Optional. If this parameter is set to true, it checks whether the search data matches the type of the array's values.

Description

If the given value search exists in the array array then it returns true. If the third parameter is set to true, the function returns true only if the element exists in the array and the data type is the same as the given value.

If the parameter is not found in the array, the function returns false.

Note:If search The parameter is a string and type If the parameter is set to true, the search is case-sensitive.

Technical Details

Return Value: If the value is found in the array, it returns TRUE, otherwise it returns FALSE.
PHP Version: 4+
Changelog: Since PHP 4.2search The parameter may also be an array now.

More Examples

Example 1

Use all parameters:

<?php
$people = array("Bill", "Steve", "Mark", "David");
if (in_array("23", $people, TRUE))
  {
  echo "Match found<br>";
  }
else
  {
  echo "Match not found<br>";
  }
if (in_array("Mark",$people, TRUE))
  {
  echo "Match found<br>";
  }
else
  {
  echo "Match not found<br>";
  }
if (in_array(23,$people, TRUE))
  {
  echo "Match found<br>";
  }
else
  {
  echo "Match not found<br>";
  }
?>

Run Example