如何将PHP中的会话数组变量存储在MySQL数据库中?

如何将PHP中的会话数组变量存储在MySQL数据库中?,php,mysql,arrays,session,Php,Mysql,Arrays,Session,会话数组变量有问题 $_SESSION ['roomsInfo_' . $intHId] = $strRTypeArr; 通过使用 如何在MySQL数据库中存储会话数组变量?只需确保以分配普通值的方式分配数组,然后将数组存储在数据库中即可 $_SESSION['dArray'] = $strRTypeArr; //for example: $strRTypeArr[0][0] = array ( 'myRoomSq' => 2.5, 'roomSeq' =>

会话数组变量有问题

$_SESSION ['roomsInfo_' . $intHId] = $strRTypeArr; 
通过使用


如何在MySQL数据库中存储会话数组变量?

只需确保以分配普通值的方式分配数组,然后将数组存储在数据库中即可

$_SESSION['dArray'] = $strRTypeArr;


//for example:
$strRTypeArr[0][0] = array (
    'myRoomSq' => 2.5,
    'roomSeq' => "test this",
    'adults' => true,
    'child' => 5,
    'childAges' => "test"
);

$strRTypeArr[0][1] = array (
    'myRoomSq' => 3.5,
    'roomSeq' => "this is another test",
    'adults' => false,
    'child' => 6,
    'childAges' => "test"
);

$_SESSION['dArray'] = $strRTypeArr; 
echo "<pre>";
print_r($_SESSION['dArray']);
echo "</pre>";

//Store this $_SESSION['dArray']  in your database

您还可以使用json_encode$_会话['dArray'];将数组存储在数据库中

这和。。
$_SESSION['dArray'] = $strRTypeArr;


//for example:
$strRTypeArr[0][0] = array (
    'myRoomSq' => 2.5,
    'roomSeq' => "test this",
    'adults' => true,
    'child' => 5,
    'childAges' => "test"
);

$strRTypeArr[0][1] = array (
    'myRoomSq' => 3.5,
    'roomSeq' => "this is another test",
    'adults' => false,
    'child' => 6,
    'childAges' => "test"
);

$_SESSION['dArray'] = $strRTypeArr; 
echo "<pre>";
print_r($_SESSION['dArray']);
echo "</pre>";

//Store this $_SESSION['dArray']  in your database