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>';
答案 0 :(得分: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>';
答案 1 :(得分: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
}
}