首页 > 后端开发 > php教程 > 如何用php遍历此数组

如何用php遍历此数组

WBOY
发布: 2016-06-06 20:21:07
原创
1070 人浏览过

<code>Array
(
    [name] => Array
        (
            [0] => 2.png
            [1] => 3.png
            [2] => 4.png
        )

    [type] => Array
        (
            [0] => image/png
            [1] => image/png
            [2] => image/png
        )

    [tmp_name] => Array
        (
            [0] => E:\phpstudy\tmp\tmp\phpDE5B.tmp
            [1] => E:\phpstudy\tmp\tmp\phpDE5C.tmp
            [2] => E:\phpstudy\tmp\tmp\phpDE5D.tmp
        )

    [error] => Array
        (
            [0] => 0
            [1] => 0
            [2] => 0
        )

    [size] => Array
        (
            [0] => 10731
            [1] => 9123
            [2] => 27612
        )

)</code>
登录后复制
登录后复制

假设此二维数组叫f,我想在遍历数组的同时,把f['name']['0']赋值给一个变量,又同时把f['tmp_name']['0']赋值给一个变量,两次赋值同时进行,请问我该怎么弄

回复内容:

<code>Array
(
    [name] => Array
        (
            [0] => 2.png
            [1] => 3.png
            [2] => 4.png
        )

    [type] => Array
        (
            [0] => image/png
            [1] => image/png
            [2] => image/png
        )

    [tmp_name] => Array
        (
            [0] => E:\phpstudy\tmp\tmp\phpDE5B.tmp
            [1] => E:\phpstudy\tmp\tmp\phpDE5C.tmp
            [2] => E:\phpstudy\tmp\tmp\phpDE5D.tmp
        )

    [error] => Array
        (
            [0] => 0
            [1] => 0
            [2] => 0
        )

    [size] => Array
        (
            [0] => 10731
            [1] => 9123
            [2] => 27612
        )

)</code>
登录后复制
登录后复制

假设此二维数组叫f,我想在遍历数组的同时,把f['name']['0']赋值给一个变量,又同时把f['tmp_name']['0']赋值给一个变量,两次赋值同时进行,请问我该怎么弄

for ($i = 0; $i < 3; $i) {

<code>$first = $f['name'][$i];
$second = $f['tmp_name'][$i];
...</code>
登录后复制

}

相关标签:
php
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板