Can someone recommend a way to break out of this for loop if an error gets put into the array error? Currently what happens is, if a bad url is entered (hopefully) that error get repeated until the for loop finishes. I’d prefer that as soon as 1 error gets entered into the array, it would then exit the for loop it is nested in.
i’ve been trying to set something up using break, but haven’t yet succeeded.,
thanks for any help on this,
i can supply a url if necessary, thanks
[code=php]if(isset($_POST[‘submit’])) {
$manId = $_POST[‘manualid’];
$url = $_POST[‘url’];
array_walk_recursive($_POST, create_function(‘&$value, $key’,’$value = trim($value);’ ));
for($i=0;$i<$count;$i++) {
$manId[$i] = prep_num($manId[$i]);
$url[$i] = prep_url($url[$i]);
if(!isValidURL($url[$i])) {
array_push($errArrUpdate, $url[$i].’ is not a valid URL’);
//BREAK OUT OF LOOP HERE, ONCE AN ERROR OCCURS
}
if(empty($errArrUpdate)) {
$sql = “UPDATE $tbl_name SET manid=’$manId[$i]’, url=’$url[$i]’ WHERE id=$id[$i]”;
//$result = mysql_query($sql);
if(!$result) {
array_push($errArrUpdate, mysql_error());
} else {
//echo ‘Update succeeded’;
}
} else {
display_errors($errArrUpdate);
}
}