combine and upload multiple inputs with foreach
<p>i have this code that submits multiple files and titles im trying to combine the results to upload to my DB and check if title[] is empty and print a custom value but im having problems with the title[] i need to combine with the s_upload[] array:</p>

<pre><code>&lt;?php
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ){

foreach ($_FILES["s_upload"]["error"] as $key =&gt; $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["s_upload"]["tmp_name"][$key];
        $name = $_FILES["s_upload"]["name"][$key];
       // move_uploaded_file($tmp_name, "data/$name");

       if ($_POST['title']==''){
       echo 'Title';
       }else{
       print_r ($_POST['title']);
       echo $name;
       }
    }
}   
}
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;/title&gt;

&lt;/head&gt;
    &lt;body&gt;


&lt;form method="post" enctype="multipart/form-data"&gt;
&lt;div class='file_upload' id='f1'&gt;
&lt;input type="text" name="title[]" id="t1"&gt;
&lt;input size="14" name='s_upload[]' id="i1" type='file'/&gt;
&lt;/div&gt;
&lt;div class='file_upload' id='f2'&gt;
&lt;input type="text" name="title[]" id="t2"&gt;
&lt;input size="14" name='s_upload[]' id="i2" type='file'/&gt;
&lt;/div&gt;
&lt;input type="submit"/&gt;
&lt;/form&gt;


    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>when i submit this is are the results:</p>

<pre><code>Array ( [0] =&gt; 11111 [1] =&gt; 22222 ) 1.jpgArray ( [0] =&gt; 11111 [1] =&gt; 22222 ) 2.jpg
</code></pre>

<p>i need this results if title exists:</p>

<pre><code>1111 1.jpg 
2222 2.jpg
</code></pre>

<p>and this results if title is empty:</p>

<pre><code>Title 1.jpg 
2222 2.jpg
</code></pre>
