prakash Posted November 22, 2007 Share Posted November 22, 2007 I am little bit confused on using variable directly under $_POST to defile another POST variable so how can extract the value of $test? currently $test outputs blank value <?php $test1=$arrayvalue[$i]; $test=$_POST[$test1]; print $test; ?> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted November 22, 2007 Share Posted November 22, 2007 Where does $arrayvalue[$i] get set/come from? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 22, 2007 Share Posted November 22, 2007 $_POST is a defined superglobal containing all if set variables defined via the http method of POST. You can't redefine them in your script you can extract their values 1 of two ways A as an associtive array or B as an indexed array. For most cases associtive is the proper method i.e $_POST['varkey']; Quote Link to comment Share on other sites More sharing options...
prakash Posted November 22, 2007 Author Share Posted November 22, 2007 it gets value from the form which is in a array form $arrayvalue=$_POST["myfield"]; Quote Link to comment Share on other sites More sharing options...
prakash Posted November 22, 2007 Author Share Posted November 22, 2007 the actual code is <?php $arrayvalue=$_POST["myfield"]; for ($i=0;$i<count($arrayvalue);$i++) { $test1=$arrayvalue[$i]; $test=$_POST[$test1]; print $test; } ?> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted November 22, 2007 Share Posted November 22, 2007 Ahh I see... You'll want to use $test1 = $_POST[$arrayvalue[$i]] Quote Link to comment Share on other sites More sharing options...
prakash Posted November 22, 2007 Author Share Posted November 22, 2007 Ahh I see... You'll want to use $test1 = $_POST[$arrayvalue[$i]] yes but it's not working Quote Link to comment Share on other sites More sharing options...
prakash Posted November 22, 2007 Author Share Posted November 22, 2007 sorry there was some mistakes on the code. it have been solved Quote Link to comment 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.