mafkeesxxx Posted September 8, 2006 Share Posted September 8, 2006 Hi!I have a string here:$_SERVER['LOGON_USER']Now, this displays the "current logged on user" Now i want to translate these usernames into realnames.Something like:username1 = Alphausername2 = Bravousername3 = CharlieI can use str_replace, but then it works only for one username, is it possible to make a code to do this for more then one username? Link to comment https://forums.phpfreaks.com/topic/20105-replace/ Share on other sites More sharing options...
Orio Posted September 8, 2006 Share Posted September 8, 2006 Sure, using arrays :)Here's an example:[code]<?php$usernames=array("User1","User2","User3");$replacement=array("Alpha","Bravo","Charlie");$user=str_replace($usernames,$replacement,$$user);?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/20105-replace/#findComment-88282 Share on other sites More sharing options...
mafkeesxxx Posted September 8, 2006 Author Share Posted September 8, 2006 [quote author=Orio link=topic=107334.msg430460#msg430460 date=1157710899]Sure, using arrays :)Here's an example:[code]<?php$usernames=array("User1","User2","User3");$replacement=array("Alpha","Bravo","Charlie");$user=str_replace($usernames,$replacement,$$user);?>[/code]Orio.[/quote]GREAT!!!Thanks dude. This was exactly what i needed! Link to comment https://forums.phpfreaks.com/topic/20105-replace/#findComment-88315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.