at0mic Posted April 6, 2009 Share Posted April 6, 2009 Instead of: $_POST['value1'] $_POST['value2'] $_POST['value3'] $_POST['value4'] $_POST['value5'] How can I auto increment them? I've tried using a while array but I cant get a variable to work inside the field. I've tried these: $_POST['value$number'] or $_POST['value{$number}'] or $_POST['value"$number"'] but none of them work. Is it possible to do? Link to comment https://forums.phpfreaks.com/topic/152784-increment-_postvalue1-_postvalue2-_postvalue3-etc/ Share on other sites More sharing options...
gevans Posted April 6, 2009 Share Posted April 6, 2009 $number = 1; echo $_POST["value$number"]; Link to comment https://forums.phpfreaks.com/topic/152784-increment-_postvalue1-_postvalue2-_postvalue3-etc/#findComment-802363 Share on other sites More sharing options...
at0mic Posted April 6, 2009 Author Share Posted April 6, 2009 Hey that works! So I was using single quotes instead of double quotes (I didn't think it would make a difference). Anyway it works so thank you so much Link to comment https://forums.phpfreaks.com/topic/152784-increment-_postvalue1-_postvalue2-_postvalue3-etc/#findComment-802444 Share on other sites More sharing options...
gevans Posted April 6, 2009 Share Posted April 6, 2009 If you wanna find out more have a read of this page CLICKY Link to comment https://forums.phpfreaks.com/topic/152784-increment-_postvalue1-_postvalue2-_postvalue3-etc/#findComment-802453 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2009 Share Posted April 6, 2009 Variables are not evaluated when contained within single quotes as this example shows: <?php $somevar = 'This is a test'; echo $somevar . "<br>\n"; echo '$somevar' . "<br>\n"; echo "$somvar<br>\n"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/152784-increment-_postvalue1-_postvalue2-_postvalue3-etc/#findComment-802454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.