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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀