Linjon Posted July 17, 2011 Share Posted July 17, 2011 Hello. How to make two variables to alphabet? Example: $variable1 = ace $variable2 = bd and script makes abcde Hope you understand, sorry for my bad English Link to comment https://forums.phpfreaks.com/topic/242218-php-alphabet/ Share on other sites More sharing options...
Alex Posted July 17, 2011 Share Posted July 17, 2011 $arr = str_split($variable1 . $variable2); sort($arr); echo implode($arr); str_split sort implode Link to comment https://forums.phpfreaks.com/topic/242218-php-alphabet/#findComment-1243878 Share on other sites More sharing options...
Linjon Posted July 17, 2011 Author Share Posted July 17, 2011 Thanks Alex. I have question again. If there is "a" in $variable1 and also there is "a" in $variable2 then it will echo "aa". How to make it show "a" once ? Link to comment https://forums.phpfreaks.com/topic/242218-php-alphabet/#findComment-1243890 Share on other sites More sharing options...
Alex Posted July 17, 2011 Share Posted July 17, 2011 Use array_unique to get rid of duplicates: $arr = str_split($variable1 . $variable2); sort($arr); echo implode(array_unique($arr)); Link to comment https://forums.phpfreaks.com/topic/242218-php-alphabet/#findComment-1243894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.