Hướng dẫn php array intersect - mảng php giao nhau

[Php 4> = 4.0.1, Php 5, Php 7, Php 8]

Array_Intersect - Tính toán giao điểm của mảngComputes the intersection of arrays

Sự mô tả

mảng_intersect [mảng $array, mảng ...$arrays]: mảng[array $array, array ...$arrays]: array

Thông số

array

Mảng có giá trị chính để kiểm tra.

arrays

Mảng để so sánh các giá trị với.

Trả về giá trị

Trả về một mảng chứa tất cả các giá trị trong array có giá trị tồn tại trong tất cả các tham số.

Thay đổi

Phiên bảnSự mô tả
8.0.0 mảng_intersect [mảng $array, mảng ...$arrays]: mảng

Thông số

arrayarray_intersect[] example

Mảng có giá trị chính để kiểm tra.

Array
[
    [a] => green
    [0] => red
]

arrays

Mảng để so sánh các giá trị với.: Two elements are considered equal if and only if [string] $elem1 === [string] $elem2. In words: when the string representation is the same.

Trả về giá trị

  • Trả về một mảng chứa tất cả các giá trị trong array có giá trị tồn tại trong tất cả các tham số.
  • Thay đổi
  • Phiên bản

Hàm này bây giờ có thể được gọi chỉ với một tham số. Trước đây, ít nhất hai tham số đã được yêu cầu.

Ví dụ

A clearer example of the key preservation of this function:

0

1

2

3

$array4

Array_diff [] - Tính toán sự khác biệt của mảng

Ví dụ

5

6

7

$array4

Ví dụ #1 Array_Intersect [] Ví dụ

Ví dụ trên sẽ xuất ra:

9

Ghi chú

Array_Diff_assoc [] - Tính toán chênh lệch của mảng với kiểm tra chỉ mục bổ sung

[string] $elem1 === [string] $elem20

[string] $elem1 === [string] $elem21

[string] $elem1 === [string] $elem22

$array4

Stuart tại Horuskol Dot Co Dot Uk ¶

Array_Diff_assoc [] - Tính toán chênh lệch của mảng với kiểm tra chỉ mục bổ sung

[string] $elem1 === [string] $elem24

[string] $elem1 === [string] $elem25

$array4

Stuart tại Horuskol Dot Co Dot Uk ¶

Ví dụ trên sẽ xuất ra:

[string] $elem1 === [string] $elem27

[string] $elem1 === [string] $elem28

[string] $elem1 === [string] $elem29

A clearer example of the key preservation of this function:0

$array4

Ghi chú

Ví dụ trên sẽ xuất ra:

A clearer example of the key preservation of this function:2

A clearer example of the key preservation of this function:3

A clearer example of the key preservation of this function:4

A clearer example of the key preservation of this function:5

A clearer example of the key preservation of this function:6

A clearer example of the key preservation of this function:7

$array4

Ghi chú

Lưu ý: Hai yếu tố được coi là bằng nhau khi và chỉ khi [string] $elem1 === [string] $elem2. Trong từ: Khi biểu diễn chuỗi giống nhau.

A clearer example of the key preservation of this function:9

Bài Viết Liên Quan

Chủ Đề