simonp Posted September 25, 2007 Share Posted September 25, 2007 Hi, Any ideas why this doesn't work: $companyaddress = array($companyaddress); $companyaddress2 = implode(", ", $companyaddress); $companyaddress is something like: 1 Smith Street Newcastle STAFFS ST5 1ED and I need it like this: 1 Smith Street, Newcastle, STAFFS, ST5 1ED Link to comment https://forums.phpfreaks.com/topic/70631-solved-implode-question/ Share on other sites More sharing options...
HuggieBear Posted September 25, 2007 Share Posted September 25, 2007 Is the original source of $companyaddress an array in the first place? Try this and paste the outcome (in code tags). var_dump($companyaddress); Regards Huggie Link to comment https://forums.phpfreaks.com/topic/70631-solved-implode-question/#findComment-354965 Share on other sites More sharing options...
HuggieBear Posted September 25, 2007 Share Posted September 25, 2007 $companyaddress is something like: 1 Smith Street Newcastle STAFFS ST5 1ED That could easily (and most likely) be a single string containing newline characters as opposed to an array containing 4 lines. Regards Huggie Link to comment https://forums.phpfreaks.com/topic/70631-solved-implode-question/#findComment-354966 Share on other sites More sharing options...
Lumio Posted September 25, 2007 Share Posted September 25, 2007 It looks like, your $companyadress is not an array. Try this: <?php $companyadress = explode("\n", $companyadress); $companyadress2 = implode(", ", $companyadress); ?> Link to comment https://forums.phpfreaks.com/topic/70631-solved-implode-question/#findComment-354969 Share on other sites More sharing options...
simonp Posted September 25, 2007 Author Share Posted September 25, 2007 Ah, I thought the $companyaddress = array($companyaddress); put the query into the array! Oh well -lumio's code did the job - thanks guys! Simon Link to comment https://forums.phpfreaks.com/topic/70631-solved-implode-question/#findComment-354996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.