Error: Call to undefined function array_in_array

sycru

问题描述

Error: Call to undefined function array_in_array 。需要判断一个数组是否在另一个数组内,但php的这个内置的函数不存在。
更正,正确写法应该是写in_array

程序代码

$arrayA = array('apple', 'banana', 'orange');
$arrayB = array('orange', 'banana', 'apple', 'pear');

$result = array_in_array($arrayA, $arrayB);
if ($result) {
   $fieldin=1;
} else {$fieldin=0;
    
}

报错信息

Error: Call to undefined function app\controller\api\home\array_in_array() in
D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\app\controller\api\home\IndexController.php:66<br />
Stack trace:<br />
#0 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\webman-framework\src\App.php(319): app\controller\api\home\IndexController->view()<br />
#1 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\webman-framework\src\App.php(141): Webman\App::Webman\{closure}()<br />
#2 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage()<br />
#3 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead()<br />
#4 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\workerman\Worker.php(1488): Workerman\Events\Select->loop()<br />
#5 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\workerman\Worker.php(1405): Workerman\Worker::forkWorkersForWindows()<br />
#6 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()<br />
#7 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()<br />
#8 D:\UPUPW_ANK_W64\WebRoot\Vhosts\WEBMAN_SITE\mgl\start.php(4): support\App::run()<br />
#9 {main}
310 1 0
1个回答

huazai

$arrayA = array('apple', 'banana', 'orange');
$arrayB = array('orange', 'banana', 'apple', 'pear');

//array_diff() 函数返回两个数组的差集,即第一个数组中存在但第二个数组中不存在的元素。如果 array_diff() 的结果为空数组,那么第一个数组中的所有元素都存在于第二个数组中
$result = array_diff($arrayA, $arrayB);
echo empty($result) ? "存在" : "不存在";

  • 暂无评论
×
🔝