Guest Posted May 23, 2007 Share Posted May 23, 2007 This code isnt working is there somting wrong with it or is there somthing different i must do? $p["$position"] Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/ Share on other sites More sharing options...
Guest Posted May 23, 2007 Share Posted May 23, 2007 Any help??? Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/#findComment-260353 Share on other sites More sharing options...
Dragen Posted May 23, 2007 Share Posted May 23, 2007 just that one little bit of code by itself doesn't really make any sense. Try posting a bit more code and explain what you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/#findComment-260356 Share on other sites More sharing options...
Guest Posted May 23, 2007 Share Posted May 23, 2007 $p['0'] = fasle; $p['1'] = fasle; $p['2'] = fasle; $p['3'] = fasle; $p['4'] = fasle; $position=1; $p['$position'] = true; I would have it do more than that but thats similar to what im doing. Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/#findComment-260361 Share on other sites More sharing options...
Dragen Posted May 23, 2007 Share Posted May 23, 2007 I presume you mean false. What you're doing there is setting the $p array. For each value setting it as false. Then the $p['$position'] = true; part, to me seems like you're setting $p[1] (1 because that's what $position equals) to true, instead of false. What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/#findComment-260364 Share on other sites More sharing options...
Guardian-Mage Posted May 23, 2007 Share Posted May 23, 2007 $position=1; $p[0] = false; $p[1] = false; $p[2] = false; $p[3] = false; $p[4] = false; $p[$position] = true; That is untested, but should work. I corrected False, as it was spelled wrong, and removed the quotes. Good luck, Brandon Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/#findComment-260368 Share on other sites More sharing options...
Glyde Posted May 24, 2007 Share Posted May 24, 2007 $p['$position'] and $p[$position] are two very different things. Take this sample script for example: <?php $p = array(); $position = 0; $p[0] = "Hello"; $p['$position'] = "world"; print $p[$position] . " " . $p['$position']; ?> That code should print "Hello World". Anything enclosed in single quotes is parsed as-is, meaning variables are not replaced if they are part of a single quoted string. Single-quoted strings should only be used for plain text, unless you plan on using a concat-syntax to add the variable, such as: 'some text ' . $variable Quote Link to comment https://forums.phpfreaks.com/topic/52730-arrayvariable/#findComment-260383 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.