I'm just looking for a MORE eloquent way of defining an array of empty error strings for a mail form then this...
$err = array('NAME'=>'', 'EMAIL'=>'', 'ADDR'=>'', 'CS_LOC'=>'', 'ZIP'=>'','PHONE'=>'', 'COMMENTS'=>'', 'FILE'=> '');
Since I have to flush these occasionally anyway, certainly anytime the form posts, I've already set up a function like the below which I call as needed, like this.
function clearFormErrors(&$ary) { // fill error array with empty strings
$keys = array_keys($ary);
$filled = array_fill_keys($keys, '');
}
Not a big deal [EDIT]:, but since I'm going to call this anyway, it would be nice if there were some nice 'wishlist' way I could just define the array **KEYS when I declare it**, like this...
$err = array('NAME', 'EMAIL, 'ADDR', 'CS_LOC, 'ZIP,'PHONE', 'COMMENTS, 'FILE');
Of course the above does NOT have that desired effect. I'm just curious if there is some simple directive or method that I've missed in the PHP docs that would just let me define the keys (with or without some default type). I'm sure there is a more complicated function that could be created to build a new array using the keys (now values) from my above 'wishlist' array, but it sounds like it wouldn't make the code any shorter or more 'eloquent', right?