WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform
Adds a smiley to the parser

bbcode_add_smiley

(No version information available, might be only in CVS)

bbcode_add_smileyAdds a smiley to the parser

Description

bool bbcode_add_smiley ( resource $bbcode_container , string $smiley , string $replace_by )

Adds a smiley to the parser

Parameters

bbcode_container

BBCode_Container resource, returned by bbcode_create().

smiley

The string that will be replaced when found.

replace_by

The string that replace smiley when found.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 bbcode_add_smiley() usage example

<?php
/*
 * Prepare the rule set 
 */
$arrayBBCode=array(
    
''=>         array('type'=>BBCODE_TYPE_ROOT,  
                       
'childs'=>'!i'),
    
'b'=>        array('type'=>BBCODE_TYPE_NOARG
                       
'open_tag'=>'<b>'
                       
'close_tag'=>'</b>'),
    
'u'=>        array('type'=>BBCODE_TYPE_NOARG
                       
'open_tag'=>'<u>'
                       
'close_tag'=>'</u>'
                       
'flags'=>BBCODE_FLAGS_SMILEYS_OFF),
    
'i'=>        array('type'=>BBCODE_TYPE_NOARG
                       
'open_tag'=>'<i>'
                       
'close_tag'=>'</i>'
                       
'childs'=>'b'),
);
/* 
 * Parsed Text
 */
$text=<<<EOF
[i] No parse Test [/i] :)
[b] Parsed, with smiley :( [/b]
[u] Parsed, with no smiley :D [/u]
EOF;
/*
 * Init the parser
 */
$BBHandler=bbcode_create($arrayBBCode);
/*
 * Add Smiley rules to parser
 */
bbcode_add_smiley($BBHandler":)""<img src=\"smiley.gif\" alt=\":)\" />");
bbcode_add_smiley($BBHandler":(""<img src=\"sad.gif\" alt=\":(\" />");
bbcode_add_smiley($BBHandler":D""<img src=\"happy.gif\" alt=\":D\" />");
bbcode_add_smiley($BBHandler":p""<img src=\"tong.gif\" alt=\":p\" />");
bbcode_add_smiley($BBHandler":|""<img src=\"special.gif\" alt=\":|\" />");
bbcode_add_smiley($BBHandler":6:""<img src=\"six.gif\" alt=\":6:\" />");
/*
 * Parse the text
 */
echo bbcode_parse($BBHandler,$text);
?>

The above example will output:

 
 [i] No parse Test [/i] <img src="smiley.gif" alt=":)" /> <b> Parsed, with smiley <img src="sad.gif" alt=":(" /> </b> <u> Parsed, with no smiley :D </u>