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 Quote 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 Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.