$file_path = "./cookies.txt"; $fp = fopen($file_path,"r"); $str = fread($fp,filesize($file_path)); $str =str_replace("\r\n","",$str); $str=explode("&",$str); $text=array(); foreach ($str as $v){ $text[]=explode(':',$v); } $textcount=count($text); for($i=0;$i<$textcount;$i++){ $cookies[$text[$i][0]]=$text[$i][1]; }
得到的$cookies就是键=>值的数组