faqts : Computers : Programming : Languages : PHP : Common Problems : Arrays

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 8 people (88%) answered Yes
Recently 7 of 8 people (88%) answered Yes

Entry

How do I convert variables my_var_1, my_var_2, etc. into an array e.g. my_var[x]?

Feb 14th, 2002 09:38
Ben Udall, Martin Hanrahan,


You could probably use something like this:
$my_var = array();
$i      = 1;
while (isset(${"my_var".$i}))
{
   $my_var[$i] = ${"my_var".$i};
   ++$i;
}