I'm building an xml excel spreadsheet on the fly (using the Pear class) and I want to be able to change the number of the last variable ($format_3) dynamically:
$sheet->write($xlsrow,$i,$thistrade,$format_3);
so I want to code automatically for $format_1, $format_2 etc
a simple concat $format_.$myvar doesnt work
and a variable variable :
$foo = 'format_'.$myvar;
$ref = "foo";
echo $$ref;
does not work when used in the xml function though the simple echo appears correct
I could do it with a clunky switch statement but there must be a better way -
any ideas?