chuy08 Posted November 6, 2006 Share Posted November 6, 2006 given the following array:$sql['city'] = 'Fremont';$sql['state']= "CA";$sql['zip'] = "94538"how would you concatenate these array variables to appear as follows:Fremont, CA 94538I have tried the following:$faddress = ($sql['city'].$sql['state'].$sql['zip']);print $faddress;But this returnsFremontCA94538How do I add spaces to this array concatenation? Link to comment https://forums.phpfreaks.com/topic/26384-concatenation-of-an-array/ Share on other sites More sharing options...
hostfreak Posted November 6, 2006 Share Posted November 6, 2006 Try:[code]$faddress = "{$sql['city']}, {$sql['state']}, {$sql['zip']}";[/code] Link to comment https://forums.phpfreaks.com/topic/26384-concatenation-of-an-array/#findComment-120658 Share on other sites More sharing options...
Barand Posted November 6, 2006 Share Posted November 6, 2006 [code]echo join(' ', $sql);[/code] Link to comment https://forums.phpfreaks.com/topic/26384-concatenation-of-an-array/#findComment-120662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.