Author |
Message |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Sat Oct 11, 2003 6:50 pm Post subject: replace help |
|
|
Ok,
Suppose i got a text like this
^1WELCOEM ^7IDIOT
^1 = Font color FF0000
^7 = Font color FFFFFF
I want the text to be displayed witht he colors
(if you view source, it should be)
<font color="FF0000">WELCOME <font color="FFFFFF">IDIOT
if you don't understand ill try and explain again....
HELP! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sat Oct 11, 2003 6:55 pm Post subject: (No subject) |
|
|
substrings!
output everything before the first ^ character. Read the int after ^ that determines the color and output appropriate HTML tag. Cut w/e your outputed out and repeat the loop untill the whole string is processed. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Sun Oct 12, 2003 12:18 am Post subject: (No subject) |
|
|
hmm still in need of help! |
|
|
|
|
![](images/spacer.gif) |
Blade
|
Posted: Sun Oct 12, 2003 2:43 pm Post subject: (No subject) |
|
|
why dont you just use functions?? |
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Sun Oct 12, 2003 4:21 pm Post subject: (No subject) |
|
|
its cuz he way the thing is set up ![Sad Sad](http://compsci.ca/v3/images/smiles/icon_sad.gif) |
|
|
|
|
![](images/spacer.gif) |
PaddyLong
|
Posted: Mon Oct 13, 2003 11:13 am Post subject: (No subject) |
|
|
use something like this...
code: |
$text = "^1WELCOEM ^7IDIOT";
$text = ereg_replace ("\^1", "<font color=\"#FF0000\">", $text);
$text = ereg_replace ("\^7", "<font color=\"#FFFFFF\">", $text);
echo $text;
|
you need the \ in front of the ^ because ^ is a special character in the regular expression syntax |
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Mon Oct 13, 2003 4:12 pm Post subject: (No subject) |
|
|
Odd, i tried that...it did not wrk idk why!!!
works if i only have one, ^#
Not if there are more then 1 ![Sad Sad](http://compsci.ca/v3/images/smiles/icon_sad.gif) |
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Mon Oct 13, 2003 5:03 pm Post subject: (No subject) |
|
|
NEVER MIND!
ya, i got it...it was a problem in my code..my other charaters ^7 and all were messed :S |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|