Jump to content

Simple coding language?


Twango

Recommended Posts

Hi there, I've been developing a simple coding language all in one PHP page...Here's what i have so far:<?php$asml = $_REQUEST['submt'];//ASML tags$asmle = eregi_replace("\*rd\*", "<font color=red>", $asml);$asmle = eregi_replace("\*b\*", "<font color=blue>", $asml);//Handlingecho "<form action='asml.php' method='post'>ASML Code: <textarea width='400' height='200' name='submt'>$asml</textarea><input type='submit' value='Go'/></form>";echo "Code on a webpage:<br/><br/> $asmle";?>Now, for some reason, say I insert *rd* This is red *b* this is blue into the textarea.it returns *rd* This is red this is blue (this is blue IS blue, This is red and *rd* is not red)I want to also make this be able to add MORE tags, too.i cant figure out what's wrong.Thanks

Link to comment
Share on other sites

Probably because you haven't put any closing </font> tags. I don't see any regular expressions so you should use str_replace() instead.Edit: Actually, you're overwriting $asmle in the second replace expression. You should use $asmle as the string the the second line:$asmle = eregi_replace("\*rd\*", "<font color=red>", $asml);$asmle = eregi_replace("\*b\*", "<font color=blue>", $asmle);

Link to comment
Share on other sites

if you are trying to make some kind of bbcode ..i am not sure this will work efficiently. *rd* if represents the starting point of the formating there must be a end point. otherwise php wont be able to determine where to stop.eregi_* is dprecated you may like to use preg_replace() insteadfor matching *rd* using regler expression pattern i think it should be something like preg_replace("/\*rd\*/",$replace,$data)you should have use some delimeterbtw you are missing quotes in atributes value too.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...