动漫人物
123456789101112131415161718192021222324252627282930313233343536373839404142434445<?php$found = false;$view = array();$view_list = isset($_SESSION['view_list'])?$_SESSION['view_list']:array();$view["utm_source"] = $_GET['utm_source'];$view["utm_medium"] = $_GET['utm_medium'];$view["utm_campaign"] = $_GET['utm_campaign'];$view["utm_content"] = $_GET['utm_content'];$time = date("Y-m-d H:i:s",time());foreach($view_list as $row){ if( $row["utm_source"]==$view["utm_source"] && $row["utm_medium"]==$view["utm_medium"] && $row["utm_campaign"]==$view["utm_campaign"] && $row["utm_content"]==$view["utm_content"] &&){ //检测重复 $found = true; break; }}if(!$found){ $view_list[$time] = $view; $_SESSION['view_list'] = $view_list; $_SESSION['last_view'] = $view;} //以上是保存访问历史部分?> <?php//下面是在提交时将数据保存到数据库的部分$view_list = json_encode($_SESSION['view_list']);//将总数组编码后的字符串$view_last = json_encode($_SESSION['last_view']);//将最后一次访问编码成字符串 //以上两个数据存入数据库即可 ?> <?php//从数据库获取数据//从数据库取到数据后进行一次json解码就可以拿到原来的数组了如下://$view_list_str $last_view_str分别是从数据库中读出来的字符串$view_list_array = json_encode($view_list_str);$view_last_array = json_encode($last_view_str); ?>