suppose I have a function like
function crear($first, $second, $third, $fourth, $fifth, $sixth){
$sixth= ($sixth > 0 ? "<span class='required'>*</span>" : "");
if($fourth=='input'){
echo "\t <div class='field-box ".$third."' id='".$first."_field_box'> \n";
echo "\t\t <div class='display-as-box' id='".$first."_display_as_box'>".$second." ".$sixth.":</div> \n";
echo "\t\t <div class='input-box' id='".$first."_input_box'> \n";
echo "\t\t <input id='field-".$first."' name='".$first."' type='text' maxlength='".$fifth."' /> </div><div class='clear'></div> \n";
echo "\t </div>\n";
}
}
And I am calling it several times:
crear('title1', 'Title 1','odd', 'input', '50', 0 );
crear('title2', 'Title 2','even', 'input', '50', 0 );
crear('title3', 'Title 3','odd', 'input', '30', 1 );
crear('title4', 'Title 4','even', 'input', '50', 0 );
crear('title5', 'Title 5','odd', 'select', '19', 1 );
crear('title6', 'Title 6','even', 'select', '19', 0 );
How could I make only one call to this function passing all this data.
I was thinking to make an array but I woul have to modify the function, What would be the best way... The only one I easily can suppose is odd and even field, the others got to be variables.
crear()several times, but definingfill()? If you don't want to modify the function itself, then put your data in an array, loop over the array, and call the function within the loop.