Re: implode()

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

 



Terion Miller wrote:
I have read the whole forum at php.net on implode and I still don't get why
this one does not work

if (isset($_POST['BannerSize'])){$BannerSize =
implode($_POST['BannerSize'],',');} else {$BannerSize = "";}

someone please help


don't think it's a php thing, it's expecting an array in the post data, so check the html form that's sending to the page; it should be sending the BannerSize field as an array

<input type="xxxxx" name="BannerSize[]" />
<input type="xxxxx" name="BannerSize[]" />
<input type="xxxxx" name="BannerSize[]" />

for future reference you can normally debug all these things yourself with a debugger or manually using var_dump or print_r; thus change you're code to:

if (isset($_POST['BannerSize'])) {
 print_r($BannerSize); //if it's not an array don't implode
 $BannerSize = implode($_POST['BannerSize'],',');
} else {
 $BannerSize = "";
}

or if you can't be bothered just do this:

if (isset($_POST['BannerSize'])) {
 if(is_array($_POST['BannerSize']) ) {
  $BannerSize = implode(',', $_POST['BannerSize']); //in right order..
 } else {
  $BannerSize = $_POST['BannerSize'];
 }
} else {
 $BannerSize = "";
}

--
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