PHP session array

前端 未结 4 1250
悲哀的现实
悲哀的现实 2020-12-22 03:20

how can i store this array into a session and use sessions to move the elements inside the array up/down/left/right diagonally

$board = array(A B C D E F G H         


        
4条回答
  •  悲&欢浪女
    2020-12-22 04:12

    Call session_start and afterwards store your variables in $_SESSION -- they will be available throughout the session:

    session_start();
    $_SESSION['board'] = array( ... );
    

    Moving elements is just a matter of assigning one value to another, for example:

    $_SESSION['board'][$new_i][$new_j] = $_SESSION['board'][$old_i][$old_j];
    $_SESSION['board'][$old_i][$old_j] = ...;
    

提交回复
热议问题