Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数组_unique不工作_Php_Arrays - Fatal编程技术网

Php 数组_unique不工作

Php 数组_unique不工作,php,arrays,Php,Arrays,我在多维数组中存储一些值,同时存储我试图在我的值中减去重复数组的值,因为我在php中使用了array_unique函数。它在本地工作,但不是在现场工作,任何人都可以帮助我。我在下面附上了我的代码 $ex = $_POST; $_SESSION["cartdetail"][] = $ex; $_SESSION["cartdetail"] = array_unique($_SESSION["cartdetail"]); echo "<pre>"; print_r($_SES

我在多维数组中存储一些值,同时存储我试图在我的值中减去重复数组的值,因为我在php中使用了array_unique函数。它在本地工作,但不是在现场工作,任何人都可以帮助我。我在下面附上了我的代码

$ex = $_POST;



$_SESSION["cartdetail"][] = $ex;



$_SESSION["cartdetail"] = array_unique($_SESSION["cartdetail"]);

echo "<pre>";
print_r($_SESSION["cartdetail"]);
echo "</pre>";

当我试图在数组中存储不同的值时,它不会存储。它只存储数组中的第一个值。感谢您的帮助

您需要序列化内部数组,然后再反序列化回来:


您在您的页面中使用会话\u start?我已将该会话\u start包含在我的首页中…..它在本地主机中工作,但在Onlinet中不工作。它正在工作,谢谢
Array
(
[0] => Array
    (
        [cid] => 7
        [cname] => studies 
        [ctype] => Class Room
        [cdate] => 12-1
        [ctime] => 09:30 am-06:30 pm
        [cdays] => 5
        [cprice] => 1
        [viewDetails] => start
    )

)
$_SESSION["cartdetail"] = array_map("unserialize", array_unique(array_map("serialize", $_SESSION["cartdetail"])));