sean123 Posted February 14, 2008 Share Posted February 14, 2008 I've got some text that I want putting in order so it is not in 1 line. The text is: username Level: 25 Ratio: 1.54 Rank: 3266 th Kills: 73761 Deaths: 9977 Experience: 674534632 That is generated when the user enters their username. Is it possible to make it in this format? username Level: 25 Ratio: 1.54 Rank: 3266 th Kills: 73761 Deaths: 9977 Experience: 674534632 Link to comment https://forums.phpfreaks.com/topic/91090-editing-this-text/ Share on other sites More sharing options...
rhodesa Posted February 14, 2008 Share Posted February 14, 2008 <?php $text = "username Level: 25 Ratio: 1.54 Rank: 3266 th Kills: 73761 Deaths: 9977 Experience: 674534632"; $nl = "\n"; //Change to <br /> for HTML print preg_replace("/\s*(\w+:)/","$nl\$1",$text); ?> Link to comment https://forums.phpfreaks.com/topic/91090-editing-this-text/#findComment-466846 Share on other sites More sharing options...
sean123 Posted February 15, 2008 Author Share Posted February 15, 2008 Thanks 1 more question. I want to put each 1 in a variable and remove anything after the colon so it would be like this: $name = "username"; $level = "25"; $ratio = "1.54"; $rank = "3266 th"; $kill = "73761"; $death = "9977"; $exp = "674534632"; Is it possible? Link to comment https://forums.phpfreaks.com/topic/91090-editing-this-text/#findComment-468034 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.