php - Checking a value in a basic multidimensional array -
this quick 1 of i'm sure, i'm banging head against wall trying teach myself multidimensional arrays.
i wish check whether or not $_files["photo"]["name"]
contains empty strings, , such code below if statement executed.
currently works, else statment (not shown), there has cleaner way of writing this??
many thanks.
if (empty($_files["photo"]["name"][0]) && empty($_files["photo"]["name"][1]) && empty($_files["photo"]["name"][2])) { $query = "insert lot (lotnumber, lottitle, lotdescription, datecreated, lastmodified) values" . "('$lotnumber', '$lottitle', '$lotdescription', null, null)"; if (!$mysqli->query($query)) { echo '<p class="warning">error executing insert query: (' . $mysqli->errno . ') ' . $mysqli->error . "</p>"; } else { echo '<p class="success">the lot has been added directory.' . "</p>" . html_linebreak; } }
i have script counts keys within "name" level.
$count = sizeof($name_of_array->photo->name);
then in loop check see if keys empty.
for($i = 0; $i <= $count; $i++) { if(empty($name_of_array->photo->name[$i]) { ... continue code } else { ... continue code } }
Comments
Post a Comment