HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 I have the following array:[code=php:0]$numbers = array(1, 2, 3, 4, 5);[/code]Now how do I get this into a variable that looks like this:[code=php:0]$number_variable = "1, 2, 3, 4, 5";[/code]I realise this is the opposite of something like explode() but wondered the easiest way to get it from an array to a variable.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/25072-create-a-variable-from-an-array-separated-by-commas/ Share on other sites More sharing options...
Wuhtzu Posted October 25, 2006 Share Posted October 25, 2006 The opposite function is simply called implode() :)So implode(",",$array) will make you a string which will contain all the strings from the array seperated by a comma (,)http://no2.php.net/implodeWuhtzu Link to comment https://forums.phpfreaks.com/topic/25072-create-a-variable-from-an-array-separated-by-commas/#findComment-114275 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Author Share Posted October 25, 2006 Perfect, I'm loving the logic in that.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/25072-create-a-variable-from-an-array-separated-by-commas/#findComment-114297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.