时间:2021-07-01 10:21:17 帮助过:18人阅读
session_start();$cate1 = $_GET['cate1'];$cate2 = $_GET['cate2'];$cate3 = $_GET['cate3'];$data[] = array('cate1'=>$cate1,'cate2'=>$cate2,'cate3'=>$cate3);if($_SESSION['cate']){ $data[] = $_SESSION['cate'];}$_SESSION['cate'] = $data;
array(2) { [0]=> array(3) { ["cate1"]=> string(2) "35" ["cate2"]=> string(2) "43" ["cate3"]=> string(2) "12" } [1]=> array(2) { [0]=> array(3) { ["cate1"]=> string(2) "35" ["cate2"]=> string(2) "43" ["cate3"]=> string(2) "12" } [1]=> array(2) { [0]=> array(3) { ["cate1"]=> string(2) "95" ["cate2"]=> string(2) "64" ["cate3"]=> string(2) "13" } [1]=> array(2) { [0]=> array(3) { ["cate1"]=> string(2) "95" ["cate2"]=> string(2) "64" ["cate3"]=> string(2) "13" } [1]=> array(1) { [0]=> array(3) { ["cate1"]=> string(2) "55" ["cate2"]=> string(2) "24" ["cate3"]=> string(2) "43" } } } } }}
session_start();$cate1 = $_GET['cate1'];$cate2 = $_GET['cate2'];$cate3 = $_GET['cate3'];$data = array('cate1'=>$cate1,'cate2'=>$cate2,'cate3'=>$cate3);if($_SESSION['cate']){ $data = $_SESSION['cate'];} $_SESSION['cate'] = $data;
这样也不行啊 版主大哥 这样取到的永远只有一个一维数组
http://localhost/test?cate1=23&cate2=34&cate3=45
http://localhost/test?cate1=24&cate2=35&cate3=46
我请求了两次它返回的都是这个数据
array(3) { ["cate1"]=> string(2) "23" ["cate2"]=> string(2) "34" ["cate3"]=> string(2) "45"}
array(3) {[0]=>{ ["cate1"]=> string(2) "23" ["cate2"]=> string(2) "34" ["cate3"]=> string(2) "45"}[1]=>{ ["cate1"]=> string(2) "24" ["cate2"]=> string(2) "35" ["cate3"]=> string(2) "46"}}
session_start();if(! isset($_SESSION['cate']) ) $_SESSION['cate'] = array();$cate1 = $_GET['cate1'];$cate2 = $_GET['cate2'];$cate3 = $_GET['cate3'];$_SESSION['cate'][] = array('cate1'=>$cate1,'cate2'=>$cate2,'cate3'=>$cate3);
靠 原来这么简单 ……。 想太复杂了 谢谢版主