Re: Correct handling _POST[] and implode. PHP5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Its Simple...

Its very obvious that $_POST["color"] is not an array.

do something like this and you wil get the values.

$arr_color = $_POST["colors"];

//iterate over the array
foreach($arr_color as $val)
{
    $str_color .= ", "  . $val;
}

You are done.

Gaurav Kumar
Teach Lead Open Source Technologies



On Fri, Oct 9, 2009 at 11:14 AM, bearsfoot <adam.p.reynolds@xxxxxxxxx>wrote:

>
> Hi all,
>
> I have a form that has has an array of information.  Mulitple checkboxes
> can
> be selected.
>
> Choose the colors:
> <input type="checkbox" name="Colors[]" value="green" checked="checked" />
> Green
> <input type="checkbox" name="Colors[]" value="yellow" /> Yellow
> <input type="checkbox" name="Colors[]" value="red" /> Red
> <input type="checkbox" name="Colors[]" value="gray" /> Gray
>
> When processing the form..
>
> echo $_POST['Colors'] . '<br />'; // outputs 'Array'
>
> if ( isset($_POST['Colors']) ) {
>     $_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array
> into a single string
> }
>
>   echo "Colors you chose: {$_POST['Colors']}<br />";
>
> I get the following error when using the implode function.
>
> Warning: implode() [function.implode]: Bad arguments
>
> What I doing wrong ?
>
> Thanks in advance.
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Correct-handling-_POST---and-implode.-PHP5-tp25815789p25815789.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux