Jump to content

Archived

This topic is now archived and is closed to further replies.

mafkeesxxx

REPLACE

Recommended Posts

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 = Alpha
username2 = Bravo
username3 = Charlie

I 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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.