yoki Posted November 14, 2008 Share Posted November 14, 2008 Hi, I have the following string: "lastname, firstname" which I need to output like this: "firstname, lastname" How do I do code this? Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/132746-solved-reversing-a-string/ Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 $name = 'lastname, firstname'; <?php $name = 'lastname, firstname'; $new = implode(', ',array_reverse(preg_split('/\s*,\s*/',$name,2))); print $new; ?> Link to comment https://forums.phpfreaks.com/topic/132746-solved-reversing-a-string/#findComment-690346 Share on other sites More sharing options...
yoki Posted November 14, 2008 Author Share Posted November 14, 2008 Thanks for the quick reply! Much appreciated! Link to comment https://forums.phpfreaks.com/topic/132746-solved-reversing-a-string/#findComment-690361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.