Bob Pilly asked earlier today:

> Does anyone know if you can assign a new variable name based on the
contents of another variable in PHP? If so whats the syntax to do this?

$counter = 1;
for ($i == 0; $i < 6; $i++) {
      ${'newVar_' . $counter} = $counter;
      $counter++;
}
echo $newVar_1 . "<br />";
echo $newVar_2 . "<br />";
echo $newVar_3 . "<br />";
echo $newVar_4 . "<br />";
echo $newVar_5 . "<br />";
echo $newVar_6 . "<br />";

This displays:

1
2
3
4
5
6

Something like this maybe?

David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to