duanjue7745 2013-01-28 13:15
浏览 238
已采纳

数组序列化问题

I'm storing some information which has been serialized by using jQuery into a MySQL database :

$(function () {
    $("#sortable").sortable({
        stop: function (event, ui) {
            $("#q35list").val($(this).sortable('serialize'));
        }
    });
    $("#sortable").disableSelection();

This stores the relevant information in the DB fine (via a .php save page).

However, when I return it and unserialize it using the following:

$arr = unserialize($results['q35list']);
if(!$arr) $arr=array();
var_dump($arr);

It' not an array! It's as follows:

string(55) "Set[]=2&Set[]=1&Set[]=3&Set[]=4&Set[]=5&Set[]=6&Set[]=7"

I am now at the point where I cannot see the wood from the trees...

  • 写回答

3条回答 默认 最新

  • doufuhao8085 2013-01-28 13:21
    关注

    jQuery serialization and PHP serialization are two separate things. jQuery focuses on being able to send the data through CGI (either GET or POST), PHP serialization focuses on storing structured data in a string.

    They are not interchangeable.

    You have to serialize and unserialize in the same platform, or it will not work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?