gpt4 book ai didi

php - 检查所有数组值是否存在于另一个数组值中

转载 作者:可可西里 更新时间:2023-11-01 01:12:27 25 4
gpt4 key购买 nike

<分区>

我有一个数组,我想与另一个数组匹配,第一个数组中的所有值都必须在第二个数组中,所以如果第二个数组长度小于第一个数组长度,它会自动变为 false。例如:

$products = array("soap","milk","book");
$availableProducts = array("soap","tea","oil","milk","book");
$this->matchArray($products,$availableProducts); //return true because all $products value inside $availableProducts value too

$products = array("soap","milk","book");
$availableProducts = array("milk","tea","book","soap","oil");
$this->matchArray($products,$availableProducts); //return true because all $products value inside $availableProducts value too

$products = array("soap","milk","book");
$availableProducts = array("soap","tea","oil","salt","paper");
$this->matchArray($products,$availableProducts); //return false because only one of $products value inside $availableProducts value

$products = array("soap","milk","book");
$availableProducts = array("milk","book");
$this->matchArray($products,$availableProducts); //return false because only two of $products value inside $availableProducts value

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com