0
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
    )

我想将数组键与第二个数组中的正确数组键匹配,例如我希望能够获取文件名

每个

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

是一个新行,我想最终将该行中的所有文件名保存在 mysql 中,以便我可以调用链接....

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

并将其与

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

所以我可以将它们一起用于文件存储等等......

下面的php是

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>';
4

2 回答 2

1

像这样的东西?

$rows = array();

foreach( $first_array as $key => $value )
{
    foreach( $value as $k => $v )
    {
        $rows[] = array( 'filename' => $v, 'path' => $second_array[$key][$k] );
    }
}

echo '<pre>' . print_r( $rows, true ) . '</pre>';
于 2013-01-31T06:36:11.293 回答
1

这就是您迭代多个上传文件的方式。假设您有这些输入元素名称:

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
    }
}
于 2013-01-31T06:39:15.363 回答