ok guys im currently creating a quite advanced CMS with group policies, content creation for sites, user administration etc for a site im working on for a client
now these guys say they have HTML knowledge but ive seen there knowledge and i certainly wouldnt call it that
now as we all know, HTML can throw up various errors when formatted incorrectly within PHP Tags (obviously seperation isnt really an option here) so i need a way for a user to click on a button and automatically write out say the correct say <font color=\"#ff0000\" tag pretty much like this 'site does it' as i dont want some idio breaking the site because he doesnt know how to format the tag correctly
can anyone advise me on how to go about this
i was looking into BBcode and diownloaded a full script for it, but cant really make any sense of it
any help would be much appreciated
Mal
[SOLVED] hard to explain! like our formatting bar on phpBB
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You can use regular expressions, for example to convert ... to bold text you could do:
You can also put a bunch of formatting options into arrays and then pass the arrays (one for the patterns to match and one for what to transform matched data to) to the [php_man]preg_replace[/php_man]() function.
Mac
Code: Select all
$formatted_text = preg_replace('/\[b\](.+?)\[\/b\]/is', '<b>\1</b>', $text_with_bbcode);Mac
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
thanks twiglettwigletmac wrote:You can use regular expressions, for example to convert ... to bold text you could do:Code: Select all
$formatted_text = preg_replace('/\[b\](.+?)\[\/b\]/is', '<b>\1</b>', $text_with_bbcode);
however is there any chance of breaking down what that string means as that just looks like a dozen/\ ive looked at the manual and it says nothing about what it means
Thanks In Advance
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Basically the regex string is:
broken down this becomes
http://php.net/manual/en/pcre.pattern.syntax.php
and on the modifiers:
http://php.net/manual/en/pcre.pattern.modifiers.php
Mac
Code: Select all
/\їb\](.+?)\ї\/b\]/is- / - the delimiters of the expression
- \[b\] = match one (the square brackets have to be escaped as they have a special meaning in regex)
- (.+?) - match any characters (the dot is any character, the plus means any number of the previous) but don't be greedy (the question mark) - stop matching when the next pattern is found. The brackets are used to enclose bits of the matched pattern that you want to replicate in the formatted text (the \1 in <b>\1</b>, if there was another lot of bracketed text this would be \2).
- \[\/b\] - match one
- i - be case-insensitive
- s - include newlines when doing the full character search (i.e. using the dot metacharacter).
http://php.net/manual/en/pcre.pattern.syntax.php
and on the modifiers:
http://php.net/manual/en/pcre.pattern.modifiers.php
Mac
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK