Jump to content


Photo

dynamically create variables


  • Please log in to reply
2 replies to this topic

#1 mister_t101

mister_t101
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 April 2006 - 03:24 PM

Is there a way to dynamically create variables by traversing an array, then naming the variable with the position in the array?

for example....

for ($i=0; $i<count($_SESSION['order']); $i++)
{
create variable named $posei;
$posei=$i;
}

Thanks for the help

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 20 April 2006 - 03:55 PM

Why not use a second array?

Info: PHP Manual


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 April 2006 - 03:57 PM

Yes. Look at [a href=\"http://www.php.net/manual/en/language.variables.variable.php\" target=\"_blank\"]variable variables[/a].

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users