dshgdhdfcas30210 2012-02-23 19:02
浏览 80
已采纳

如何将此多维数组放入SQL-DB单元格?

I have this multidimensional array:

Array
(
    [tennis] => Array
        (
            [3] => Seattle
            [4] => WA
            [5] => 98109
        )

    [Middle East] => Array
        (
            [6] => 2066822513
            [7] => 34740 - Georgetown Keg - 1/2 Manny Pale
            [0] => Hello World
        )

    [Florida] => Array
        (
            [1] => 38380 - Thirteen Coins-Boren
            [2] => 125 Boren Ave N
            [3] => Seattle
        )

)

I am looking for a way to best store it into one single cell in my SQL-DB. The keys of the main array (tennis, middle east, florida) have to be kept. The other keys of the subarrays can be omitted. How can I do that?

  • 写回答

3条回答 默认 最新

  • doumor942473 2012-02-24 10:06
    关注

    I read about the serialize function, and implemented it.

    The solution: First I turn the array into a string:

    $array = serialize($array);

    Then I store the string into the DB cell.

    To get back the array, I unserialize the string from the DB cell:

    $array = unserialize($array);

    And I end up with the same array. Simple

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

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?