html - PHP in _POST data -


recently i've come across situation using dynamic variable in _post setting valuable, doesn't seem work. example:

for($i = 0; $i<$limit; $i++){ if (isset($_post['value_{$i}'])){ // } } 

the values _post work fine; if hard code '1' or '2' in there, data. doesn't seem agree {$i} inside _post. know why?

you need use double quotes parse variables in strings, eg

for($i = 0; $i<$limit; $i++){ if (isset($_post["value_{$i}"])){ // } } 

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -