help...
Moderator: General Moderators
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
help...
I'm making a little forum/guestbook/message board thing, and was making my own little ocde, like BBcode and VBcode, but i've come across a problem. What i'm doing is just searching through the inputted text and replacing the tags, BUT i need a good way to continue to search through and find all the tags... anyone got any ideas?
Thanks
Thanks
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
lol, ya my question was sort of cryptic. The way im searching for the tags is jstu using strpos() and substr_replace() to change the tags accordingly. Problem is it only does one tag... i need a good way to keep looping through the text and change all the tags. i thought about jsut checking for "[" int he text, but the user might put a "[" in there and it would just loop over and over again. was tha any clearer?
If you are currently using preg_match try using preg_match_all
Ok, I guess you're not using preg_match. I would advise that you do, and use regular expressions to replace the code tags.
Editpreg_match_all wrote:After the first match is found, the subsequent searches are continued on from end of the last match.
Ok, I guess you're not using preg_match. I would advise that you do, and use regular expressions to replace the code tags.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
Code: Select all
<?php
$search = array('[ b]', '[ /b]', '[ i]', '[ /i]' ..etc);
$replace = array('<b>', '</b>', '<i>', '</i>' ..etc);
?>
Last edited by McGruff on Tue Aug 09, 2005 5:38 pm, edited 1 time in total.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm