/* $M is an object $M->formfields is an array of different objects */ foreach($M->formfields as $ff) { if($ff->required) { if($M->errorchex($ff->name, $ff->label, $ff->errormessage)) { $ff->error=true; } // if errorchex function returns true, set the error value on the field object to true // when the form is shown again the label will have a class=error } } print_r($ff); array_print_r($M->formfields); /* the 1 $ff that gets it error value set to true shows error=true in the print_r But when I loop through the $M->formfields array of objects, that particular one shows as not having error set to true why? */