php - set variables to global scope within a loop -


i want define number of temporary global variables in php called $myglobalvar1, $myglobalvar2 ... , problem keyword 'global' takes variable name literally:

for ($i = 1; $i<= 10; $i++) {      $var = '$myglobalvar'.$i;     global $var; } 

i.e. $var global.

setting quotes not work because 'global' expects '$' , stop execution @ single quote:

for ($i = 1; $i<= 10; $i++) {      $var = '$myglobalvar'.$i;     global '$var'; } 

how set variables global scope? thanks.

since using ' taken string

try $globals purpose

for ($i = 1; $i<= 10; $i++)  {  // acess $globals['myglobalvar'.$i] , whatever want    $globals['myglobalvar'.$i] = null } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -