Jump to content

REPLACE


mafkeesxxx

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?
Link to comment
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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.