【发布时间】:2020-01-22 15:57:42
【问题描述】:
我正在尝试使用in_array 函数来检查第二个数组中是否存在该值。我想从以下数组中搜索 556729685:
$_SESSION["cart_item"] =
Array
(
[cart_item] => Array
(
[0] => Array
(
[product_name] => White Sakura Necktie
[id] => 11
[product_auto_id] => 556729685
[quantity] => 2
[product_regular_price] => 95
[product_sale_price] => 95
[product_image] => 556729680Black_Sakura_Necktie.jpg
)
[1] => Array
(
[product_name] => hhhad ba bhdbh
[id] => 10
[product_auto_id] => 951790801
[quantity] => 2
[product_regular_price] => 20
[product_sale_price] =>
[product_image] => 951790801hhhad_ba_bhdbh_.jpg
)
)
)
我正在使用以下功能进行检查,但输出错误:
in_array(556729685, array_keys($_SESSION["cart_item"]));
我也试过这个:
in_array(556729685, array_values($_SESSION["cart_item"]));
没有工作,所以请帮我解决这个问题。
【问题讨论】:
标签: arrays session associative-array