Re: implode()
| From: | Nathan Rixham | Date: | Tue, 18 Nov 2008 15:12:34 +0000 |
| Subject: | Re: implode() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-283462@lists.php.net to get a copy of this message | ||
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 helpdon'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 = ""; }