Global works... ----- Original Message ----- From: "Jennifer Goodie" <[EMAIL PROTECTED]> To: "Boyd Pearson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, September 24, 2003 3:44 PM Subject: RE: [PHP] rename variables
> > I'm trying to rename some variables. > > > > first I have a function - > > randomize (3,4); //has created unique $numbers > > > > then I want to create a function for the renaming: > > > > renameit($sculp); //sends $sculp for the new variable name > > > > and this function (and variations) > > > > function renameit($var){ > > $z = 1; > > foreach ($numbers as $currNum){ > > $var[$z++] = $output[$currNum]; //creates $sculp[1 and 2] > > } > > } > > > > but failed > > > > if I use > > $z = 1; > > foreach ($numbers as $currNum){ > > $sculp[$z++] = $output[$currNum]; > > > > after randomize (3,4); > > > > it works fine -but I want it in a function. > > > > Any suggestions? > > Read up on scope. If you want $numbers to be available to your function it > has to be in that function's scope. Either pass it or declare it global. > > http://us2.php.net/variables.scope > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php