If you know what all the variables are, you can do something like this:
<?php
$test1 = 123;
$test2 = "Mike";
$testvar23 = "foo";
$a_vars = array("test1",
"test2",
"test3",
"test4",
"testvar22",
"testvar23"
);
echo "Display variables. Some may be empty:<br>";
foreach ($a_vars as $a) {
echo " " . $a . ": " . $$a . "<br>";
}
echo "<br>Fill empty variables with '0' and display again:<br>";
foreach ($a_vars as $b) {
$$b = (empty($$b)?"0":$$b);
echo " " . $b . ": " . $$b . "<br>";
}
?>
However, if it's crucial that all variables have an initial value of "0", then you should simply set them all to "0" at the beginning of your script.