IT. Expert System.

PHP

Adds a smiley to the parser


bbcode_add_smiley

(PECL bbcode >= 0.10.2)

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> 



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 432 / 158735410. Delta: 0.00493 с