PHP array_intersect() ফাংশন

উদাহরণ

দুই এক্সেলেন্সের কী-মান তুলনা করে এবং সমন্বয় রিটার্ন করা

<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("e"=>"red","f"=>"green","g"=>"blue");
$result=array_intersect($a1,$a2);
print_r($result);
?>

Run Example

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

array_intersect() ফাংশন দুই (বা আরও বেশি) এক্সেলেন্স কী-মান তুলনা করে এবং সমন্বয় রিটার্ন করে

এই ফাংশন দুই (বা আরও বেশি) এক্সেলেন্স কী-মান তুলনা করে এবং সমন্বয় এক্সেলেন্স রিটার্ন করে, যা সমস্ত তুলনা করা এক্সেলেন্সগুলিতে অন্তর্ভুক্ত হয়array1)}array2 or array3 etc.)

Description

The array_intersect() function returns an intersection array of two or more arrays.

The result array includes all values that are present in the compared arrays and also appear in all other parameter arrays, while the key names remain unchanged.

Note:Only values are used for comparison.

Syntax

array_intersect(array1,array2,array3...);
Parameters Description
array1 Required. The first array to compare with other arrays.
array2 Required. The array to compare with the first array.
array3,... Optional. Other arrays to compare with the first array.

Technical Details

Return Value: Returns an intersection array that includes all keys that are present in the compared array (array1) and also in any other parameter array (array2 or array3, etc.).
PHP Version: 4.0.1+

More Examples

Example 1

Compare the keys of three arrays and return the intersection:

<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("e"=>"red","f"=>"black","g"=>"purple");
$a3=array("a"=>"red","b"=>"black","h"=>"yellow");
$result=array_intersect($a1,$a2,$a3);
print_r($result);
?>

Run Example