Twango Posted March 14, 2011 Share Posted March 14, 2011 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 More sharing options...
Ingolme Posted March 14, 2011 Share Posted March 14, 2011 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 More sharing options...
birbal Posted March 14, 2011 Share Posted March 14, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.