r-it Posted January 14, 2009 Share Posted January 14, 2009 Hi guys, i am having a problem with $_POST. I am looking at parsing variables dynamically using post: $txt = "txtBox"; for($i = 1; $i <= 5; $i++) { $txt .= "_".$i; $var = $_POST[$txt]; echo $var; } the code i'm using is similar to the one above, but it does not ouptup anything, and i have tried inserting single quotes as well, please help Link to comment https://forums.phpfreaks.com/topic/140796-parsing-to-_post-dynamically/ Share on other sites More sharing options...
trq Posted January 14, 2009 Share Posted January 14, 2009 foreach ($_POST as $k => $v) { if (substr($k, 0, 5) == 'txtBox') { echo $v; } } Link to comment https://forums.phpfreaks.com/topic/140796-parsing-to-_post-dynamically/#findComment-736921 Share on other sites More sharing options...
dawsba Posted January 14, 2009 Share Posted January 14, 2009 <? $txt = "txtBox"; for($i = 1; $i <= 5; $i++) { $txt2 = $txt."_".$i; if(isset($_POST[$txt2])){$var = $_POST[$txt2];}else{unset($var);unset($txt2);} echo $var."<br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/140796-parsing-to-_post-dynamically/#findComment-736955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.