检查数组值 - PHP

How to check the condition in array, for example,

for ($i=0; $i<count($_FILES['uploaded']['name']); $i++) {
    $tmpFilePath = $_FILES['uploaded']['tmp_name'][$i];
    $filesize = $_FILES['uploaded']['size'][$i];

    if ($tmpFilePath != '' || !empty($tmpFilePath)) {
        // if condition is true upload the images and stored in db.
    } else {
        //no image uploaded.
   }
}

In my case, user can upload up to 3 images. On the condition above, how to check:

Array
    (
        [1] => filename
        [2] => filename
        [3] => 
    )

The above will still be true but on my code, it will goes to false.

Solution

for ($i=0; $i < count($_FILES['uploaded']['name']); $i++) {
    $tmpFilePath = $_FILES['uploaded']['tmp_name'][$i];
    $filesize = $_FILES['uploaded']['size'][$i];

    if ($tmpFilePath != '' || !empty($tmpFilePath)) {
      // sql to insert to db here
      $result = mysqli_query($conn, $sql);
      if (mysqli_query($conn, $sql)) {
        $pr_idEnc = urlencode(encryptor('encrypt', $pr_id));
        // mysqli_close($conn); 
        header("Location: ".BASE_PATH."update-purchase.php?success&pr_id=".$pr_idEnc."");                   
      } else {
        echo "Error updating record: " . mysqli_error($conn);
        // mysqli_close($conn);
      }
}
mysqli_free_result($result);
mysqli_close($conn); // edit here 

Find out the problem is because of the mysqli_close($conn) inside the for loop. Please let me know or give me an advise if my coding is wrong or can be improve. Thanks