bbcode_add_smiley
(PECL bbcode >= 0.10.2)
bbcode_add_smiley — Adds a smiley to the parser
Description
$bbcode_container
, string $smiley
, string $replace_by
) : boolAdds 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.
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>
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.bbcode-add-smiley.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.