unidox Posted May 29, 2008 Share Posted May 29, 2008 Is there anyway to turn an array value into a variable. Like: array("1","2",); into: $1 $2 Link to comment https://forums.phpfreaks.com/topic/107890-possible/ Share on other sites More sharing options...
paulman888888 Posted May 29, 2008 Share Posted May 29, 2008 Answer to your question YES Link to comment https://forums.phpfreaks.com/topic/107890-possible/#findComment-553067 Share on other sites More sharing options...
unidox Posted May 29, 2008 Author Share Posted May 29, 2008 How would I do it? Link to comment https://forums.phpfreaks.com/topic/107890-possible/#findComment-553069 Share on other sites More sharing options...
trq Posted May 29, 2008 Share Posted May 29, 2008 Variables must start with letters or underscores (not numbers) for starters. Why do you think you need to do this? Link to comment https://forums.phpfreaks.com/topic/107890-possible/#findComment-553075 Share on other sites More sharing options...
unidox Posted May 30, 2008 Author Share Posted May 30, 2008 I have a function inside an object to process a form, and I want to type in an array and turn it into variables to process the sql and other checks. How can I turn an array into variables? Link to comment https://forums.phpfreaks.com/topic/107890-possible/#findComment-553152 Share on other sites More sharing options...
trq Posted May 30, 2008 Share Posted May 30, 2008 No idea if this will help, your description is still pretty unclear. <?php $a = 'foo'; $b = 'bar'; $x = array('a','b'); foreach ($x as $y) { echo $$y; } ?> Link to comment https://forums.phpfreaks.com/topic/107890-possible/#findComment-553156 Share on other sites More sharing options...
The Little Guy Posted May 30, 2008 Share Posted May 30, 2008 $arr = array('a','b','c'); foreach($arr as $v){ eval('$'.$v.' = "some value";'); } echo $a.'<br>'.$b.'<br>'.$c; Link to comment https://forums.phpfreaks.com/topic/107890-possible/#findComment-553164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.