我正在构建一个用户可以使用该站点并输入数据的站点。然而,为了保存他们的数据,他们需要登录我的网站(使用 facebook connect)。他们输入的数据存储在具有以下结构的 php 多维数组中:
$order = array();
$order[] = array('rank'=>'1', 'day'=>'Tues'); // This $order[] has input inputted several times by the user
// I haven't included all the code because it's big, all that's really needed is to see the structure of $order
我的问题是,如何将 php 多维数组转换为 javascript,然后如何使用 localStorage.setItem() 将其存储到 localStorage 中,这样一旦他们使用 facebook connect 登录,我就可以使用该数据?这是最好的方法还是我应该做其他事情?
<?php
require_once 'src/facebook.php';
$order = array();
$order[] = array('rank'=>$column, 'day'=>$day);
$loginUrl = $facebook->getLoginUrl(array('scope'=>'user_about_me,email'));
?>
<html>
<head>
<script type="text/javascript">
function fblogin() {
var fk = "<?php echo $loginUrl; ?>";
// What do I do here to convert $order into javascript?
// What do I do here to store converted $order onto localStorage()
window.location = "<?php echo $loginUrl; ?>";
}
</script>
</head>
<body>
<INPUT type="image" src="img/fb.png" onclick="fblogin()" />
</body>
</html>