dpli36193 2011-03-31 14:39
浏览 237
已采纳

将多维数组值存储到MySQL(PHP)中

I have a large multidimensional array that I would like to store into a MySQL database.

Below is an example of the array in question:

Array
(
    [user1] =>
        [name] => abc
        ...
        [address] => xyz
    ...
    ...
    [user2] =>
        [name] => abc
        ...
        [address] => xyz
}

The array values and database table columns all match (apart from the rowid in the database). I have seen various methods of doing something similar, but haven't found a way that works in this solution.

Many thanks :)

Update

Updated the array structure to give a clearer idea whats in the array itself.

  • 写回答

6条回答 默认 最新

  • dtup3446 2011-03-31 15:27
    关注

    In the end I took the time to use a for loop and achieve the following:

    for ($i = 0; $i < 25; $i++)
        {
            $name = $parts[$i][0];
            $address = $parts[$i][22];
    
            // Run SQL query using the variable values rather than the array values.
        }
    

    I'm sure there is a more sophisticated way of achieving this, but this worked for now!

    Thanks all.

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作