php array_intersect和array_intersect_assoc函数用于关联数组显示错误

时间:2018-09-04 12:05:15

标签: php arrays

我试图如下所示获取这两个数组中的公共值,我也尝试了array_intersect方法

数组1:

    Array
(
    [0] => Array
        (
            [gcr_id] => 210
        )

    [1] => Array
        (
            [gcr_id] => 219
        )

    [2] => Array
        (
            [gcr_id] => 271
        )

)

数组2:

Array
(
    [0] => Array
        (
            [gcr_id] => 220
        )

    [1] => Array
        (
            [gcr_id] => 270
        )

)

我使用array_intersect_assoc($arr1,$arr2)

它显示以下错误

A PHP Error was encountered
Severity: Notice

Message: Array to string conversion

Filename: newapi/Arena.php

Line Number: 255

Backtrace:

File: /home/kodwell/public_html/avinash_workspace/hoyo_new/application/controllers/newapi/Arena.php
Line: 255
Function: array_intersect_assoc

并显示输出以及错误

或任何其他获取此类结构公共数据的方法,谢谢

0 个答案:

没有答案