doushuo1080 2013-01-31 06:27
浏览 57
已采纳

从多维数组中获取数据

Array
(
[1] => Array
    (
        [0] => purple.txt
        [1] => pinky.txt
        [2] => original stuff.txt
    )

[2] => Array
    (
        [0] => purp1.txt
        [1] => pink1.txt
        [2] => original stuff1.txt
        [3] => increment1.txt
    )

)
Array
(
[1] => Array
    (
        [0] => C:\wamp\tmp\php6395.tmp
        [1] => C:\wamp\tmp\php63A6.tmp
        [2] => C:\wamp\tmp\php63A7.tmp
    )

[2] => Array
    (
        [0] => C:\wamp\tmp\php63A8.tmp
        [1] => C:\wamp\tmp\php63A9.tmp
        [2] => C:\wamp\tmp\php63AA.tmp
        [3] => C:\wamp\tmp\php63AB.tmp
    )

I would like to match the array keys with the proper array keys from the second array for example I would like to be able get the file name

each

[1] => Array
[2] => Array

is a new row and I would like to eventually save all the file names from that row in mysql so i can call the links....

[1] => Array
    (
        [0] => purple.txt

and match it with

[1] => Array
    (
        [0] => C:\wamp\tmp\php6395.tmp

so I can use them together for file storage and so on......

The following php is

if(isset($_FILES['file'])=== true){
$files = $_FILES['file']['name'];
$files_tmp = $_FILES['file']['tmp_name'];

echo '<pre>';
print_r ($files);
echo '<pre>';

echo '<pre>';
print_r ($files_tmp);
echo '<pre>';
  • 写回答

2条回答 默认 最新

  • duanduan8439 2013-01-31 06:39
    关注

    This is how you would iterate over multiple uploaded files. Assuming you have these input element names:

    file[0][0]
    file[0][1]
    file[1][0]
    ...
    
    foreach ($_FILES['file']['name'] as $row => $rowfiles) {
        foreach ($rowfiles as $index => $name) {
            $tmp_name = $_FILES['file']['tmp_name'][$row][$index];
    
            // do stuff with $name and $tmp_name
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 poi合并多个word成一个新word,原word中横版没了.
  • ¥15 求MCSCANX 帮助
  • ¥15 机器学习训练相关模型
  • ¥15 Todesk 远程写代码 anaconda jupyter python3
  • ¥15 我的R语言提示去除连锁不平衡时clump_data报错,图片以下所示,卡了好几天了,苦恼不知道如何解决,有人帮我看看怎么解决吗?
  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 VUE项目怎么运行,系统打不开