$keyword = $this->request->param(‘keyword‘); if(cookie(‘keyword‘)){ $history = explode(‘,‘,cookie(‘keyword‘)); array_unshift($history,$keyword); $history = array_unique($history); cookie(‘keyword‘,implode(‘,‘,$history),3600); }else{ cookie(‘keyword‘,$keyword,3600); } if (!empty(cookie(‘keyword‘) )) { $histroy = explode(‘,‘, cookie(‘keyword‘) ); foreach ($histroy as $key => $val) { $histroy_list[$key][‘history‘] = $val; } }
原文:https://www.cnblogs.com/aln0825/p/12213621.html