這是程式碼
<code>function get() { session_start(); $data = $this->db->fetchAll("SELECT * FROM session"); foreach ($data as $key => &$value) { $need = stripcslashes($value['session_data']); session_decode($need); $value['session_data'] = $_SESSION; } var_dump($data); } private function copyArr($arr) { $copyArr = []; foreach ($arr as $key => $value) { $copyArr[$key] = $value; } return $copyArr; } </code>
我呼叫了copyArr函數後:(結果就不一樣了)
這是程式碼
<code>function get() { session_start(); $data = $this->db->fetchAll("SELECT * FROM session"); foreach ($data as $key => &$value) { $need = stripcslashes($value['session_data']); session_decode($need); $value['session_data'] = $_SESSION; } var_dump($data); } private function copyArr($arr) { $copyArr = []; foreach ($arr as $key => $value) { $copyArr[$key] = $value; } return $copyArr; } </code>
我呼叫了copyArr函數後:(結果就不一樣了)