Re: passing array in form HELP!
| From: | Joe Stump | Date: | Mon, 04 Dec 2000 21:20:38 +0000 |
| Subject: | Re: passing array in form HELP! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28638@lists.php.net to get a copy of this message | ||
Do this:
if(!is_array($var))
{
if(strlen($var))
{
$var = explode(',',$var);
}
else
{
$var = array();
}
}
if(!sizeof($var))
{
$var = array('Joe','Schmoo','Foo','Bar');
}
echo '<INPUT TYPE="hidden" NAME="var"
VALUE="'.implode(',',$var).'">'."\n";
On Mon, Dec 04, 2000 at 03:13:58PM -0600, John Hanson wrote:
> I can not get an array to pass in a form as a hidden variable! It allways returns a string.
> I want to pass additional info in a form (not info in the form itself) with POST method
> This is what I'm doing:
>
> IN FORM------>
> $info=array("first_name"=>"John",
> "middle_init"=>"R",
> "last_name"=>"Hanson");
>
> echo "<input type=\"hidden\" name=\"info\"
> value=\"".$info."\">";
>
> IN 2nd PAGE---->
> $info=$HTTP_POST_VARS["info"];
>
> THIS LINE;
> echo "info is=>".gettype($info);
>
> PRINTS --->
> info is=>sring
>
> WHY IS IT A STRING??
>
>
>
>
-----
Joe Stump, PHP Hacker
joestump98@yahoo.com
http://www.miester.org/
Need a programmer? http://www.google.com/search?q=%22Joe+Stump%22
*****************************************************************
* RENT THIS SPACE - SEEN BY THOUSANDS EACH DAY! *
* Current Sponsor: http://www.smackdown.com
*
*****************************************************************