AE117 Posted December 13, 2009 Share Posted December 13, 2009 The title makes it sound easy but here is what I am trying to accomplish. I have a form where there is a text feild with the name="name[]" Now I setup a simple foreach foreach ($_POST[name] as $value) { code to ex } Now this works as it gives me the value of the field. I ran into a wall trying to pull not only the value of the field but the id as well. So now lets say the field is as name="name[]" id ="Dynamic from PHP" value = "Dymnamic from php" With a, foreach, is it possible to get both the value as well as the id value? Thanks Link to comment https://forums.phpfreaks.com/topic/184966-php-foreach/ Share on other sites More sharing options...
Buddski Posted December 13, 2009 Share Posted December 13, 2009 just put the ID in the square brackets like this.. name="name[Dynanic from PHP]" id ="Dynamic from PHP" value = "Dymnamic from php" and then call with.. foreach ($_POST['name'] as $id=>$value) Link to comment https://forums.phpfreaks.com/topic/184966-php-foreach/#findComment-976418 Share on other sites More sharing options...
AE117 Posted December 13, 2009 Author Share Posted December 13, 2009 Aha that's great I need to stop drinking will coding. I appreciate it. Link to comment https://forums.phpfreaks.com/topic/184966-php-foreach/#findComment-976420 Share on other sites More sharing options...
Buddski Posted December 13, 2009 Share Posted December 13, 2009 No worries.. I do my best work with a few brewski's under the belt Link to comment https://forums.phpfreaks.com/topic/184966-php-foreach/#findComment-976422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.