dougal85 wrote:Uuuugh, yes it has. did you even try it?
Works for me 🙂
If all these variables contain the same sort of data and if they're all to be worked on as a group (in other words, if "var1", "var2", ..., are their real names and they aren't misleading) then I'd put them in an array to start with and keep them there for as long as I need to keep working on them as a group. (Naming the fields "var[1]", "var[2]", ... instead would help in this).
Otherwise you might as well keep writing repeating lines like
$var1 = ucwords(strtolower($var1));
//...
Because you'll just be writing repeating lines as per dougal85's code to put references them into an array.
Well, you could write
$arr = array();
foreach(array('myvar1', 'myvar2', 'myvar3', 'myvar4') as $var)
$arr[] = &$$var;
But you'd still have to write all of the variable names out by hand. It would be much nicer to be able to skip the whole palaver of piles of individual variables and go
$vars = array_map('ucwords', array_map('strtolower', $vars));