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? Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment 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.