aebstract Posted February 3, 2009 Share Posted February 3, 2009 Don't know how to topic this, but I have an input like this: <input type=\"text\" name=\"$id$material\" value=\"{$array3['qty']}\" size=\"3\" maxlength=\"3\" /> Maybe I should say, several inputs. They each have a unique name as you can see. No two will be the same with this method. Now while I'm running another script after this has been submitted, I'm needing to do something if the name of this input field matches the id/material that I am currently at in my loop. So I need to compare the name before I grab the value. I have no problem grabbing the value of my inputs with a $_POST[$id$material] type of thing. Quote Link to comment https://forums.phpfreaks.com/topic/143684-see-the-name-of-an-input-field/ Share on other sites More sharing options...
Maq Posted February 3, 2009 Share Posted February 3, 2009 Use double $$ before the variable to get the actual variable name. Quote Link to comment https://forums.phpfreaks.com/topic/143684-see-the-name-of-an-input-field/#findComment-753915 Share on other sites More sharing options...
aebstract Posted February 3, 2009 Author Share Posted February 3, 2009 Would it be: $postqty = $id2.$material2; echo "$$_POST[$postqty]"; or $postqty = $id2.$material2; echo "$_POST[$$postqty]"; The first one doesn't echo anything and the second one produces a white page. edit: the actual post should be $_POST['4mild'] or $_POST['8stainless'] something like that, which I'm needing to do a certain task whenever I get to the spot in my loop where idmaterial is = the piece inside that post bracket. Hope this makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/143684-see-the-name-of-an-input-field/#findComment-753922 Share on other sites More sharing options...
Philip Posted February 3, 2009 Share Posted February 3, 2009 Here we go, $a = array('help4'=>'657', 'blue1' => '999'); $first = 'help'; $last = '4'; echo $a[$first.$last]; //echos 657 Quote Link to comment https://forums.phpfreaks.com/topic/143684-see-the-name-of-an-input-field/#findComment-753929 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.