3v4l.org

run code in 300+ PHP versions simultaneously
<?php function emote($source) { $emotes = array( '/(\:\))|(\:\=\))|(\:\-\))/' => 'smile', '/(\:\()|(\:\=\()|(\:\-\()/' => 'sadsmile', '/(\:D)|(\:\=D)|(\:\-D)/i' => 'bigsmile', '/(8\))|(8\=\))|(8\-\))|(B\))|(B\=\))|(B\-\))|(\(cool\))/i' => 'cool', '/(\:o)|(\:\=o)|(\:\-o)/i' => 'wink', '/(\;\()|(\;\-\()|(\;\=\()/' => 'crying', '/(\(sweat\))|(\(\:\|)/i' => 'sweating', '/(\:\|)|(\:\=\|)|(\:\-\|)/' => 'speechless', '/(\:\*)|(\:\=\*)|(\:\-\*)/' => 'kiss', '/:P:=P:-P/i' => 'tongueout', '/(\(blush\))|(\:\$)|(\:\-\$)|(\:\=\$)|(\:\"\>)/i' => 'blush', '/(\:\^\))/' => 'wondering', '/(\|\-\))|(\I\-\))|(\I\=\))|(\(snooze\))/i' => 'sleepy', '/(\|\()|(\|\-\()|(\|\=\()/' => 'dull', '/(\(inlove\))/i' => 'inlove', '/(\]\:\))|(>\:\))|(\(grin\))/i' => 'evilgrin', '/(\(talk\))/i' => 'talking', '/(\(yawn\))|(\|\-\(\))/i' => 'yawn', '/(\(puke\))|(\:\&)|(\:\-\&)|(\:\=\&)/i' => 'puke', '/(\(doh\))/i' => 'doh', '/(\:\@)|(\:\-\@)|(\:\=\@)|(\x\()|(\x\-\()|(\x\=\()/i' => 'angry', '/(\(wasntme\))/i' => 'wasntme', '/(\(party\))/i' => 'party', '/(\:S)|(\:\-S)|(\:\=S)/i' => 'worried', '/(\(mm\))|(\(mmm\))/i' => 'mmm', '/(8\-\|)|(B\-\|)|(8\|)|(B\|)|(8\=\|)|(B\=\|)|(\(nerd\))/i' => 'nerd', '/(\:x)|(\:\-x)|(\:\=x)|(\:\#)|(\:\-\#)|(\:\=\#)/i' => 'lipssealed', '/(\(hi\))/i' => 'hi', '/(\(call\))/i' => 'call', '/(\(devil\))/i' => 'devil', '/(\(angel\))/i' => 'angel', '/(\(envy\))/i' => 'envy', '/(\(wait\))/i' => 'wait', '/(\(bear\))|(\(hug\))/i' => 'bear', '/(\(makeup\))|(\(kate\))/i' => 'makeup', '/(\(giggle\))|(\(chuckle\))/i' => 'coveredlaugh', '/(\(clap\))|(\(applaud\))|(\(applause\))/i' => 'clapping', '/(\(think\))|(\:\?)|(\:\-\?)|(\:\=\?)/i' => 'thinking', '/(\(bow\))/i' => 'bow', '/(rofl)|(\(rofl\))/i' => 'rofl', '/(\(whew\))|(\(phew\))/i' => 'whew', '/(\(happy\))/i' => 'happy', '/(\(smirk\))/i' => 'smirking', '/(\(nod\))/i' => 'nodding', '/(\(shake\))/i' => 'shaking', '/(\(punch\))/i' => 'punch', '/(\(emo\))/i' => 'emo', '/(\(y\))|(\(ok\))/i' => 'yes', '/(\(n\))/i' => 'no', '/(\(handshake\))/i' => 'handshake', '/(\(skype\))|(\(ss\))/i' => 'skype', '/(\(h\))|(\(l\))/i' => 'heart', '/(\(u\))/i' => 'brokenheart', '/(\(e\))|(\(m\))/i' => 'mail', '/(\(f\))/i' => 'flower', '/(\(rain\))|(\(london\))|(\(st\))/i' => 'rain', '/(\(sun\))/i' => 'sun', '/(\(o\))|(\(time\))|(\(clock\))/i' => 'clock', '/(\(8\))|(\(music\))/i' => 'music', '/(\(\~\))|(\(film\))|(\(movie\))/i' => 'movie', '/(\(mp\))|(\(ph\))|(\(phone\))|(\(mobile\))|(\(cell\))/i' => 'phone', '/(\(coffee\))/i' => 'coffee', '/(\(pizza\))|(\(pi\))|(\(za\))/i' => 'pizza', '/(\(cash\))|(\(mo\))|(\(\$\))/i' => 'cash', '/(\(muscle\))|(\(flex\))/i' => 'muscle', '/(\(\^\))|(\(cake\))/i' => 'cake', '/(\(beer\))/i' => 'beer', '/(\(d\))/i' => 'drink', '/(\(dance\))|(\\\o\/)|(\\\:D\/)/i' => 'dance', '/(\(ninja\))/i' => 'ninja', '/(\(\*\))|(\(star\))/i' => 'star', '/(\(mooning\))/i' => 'mooning', '/(\(finger\))/i' => 'finger', '/(\(smoking\))|(\(smoke\))|(\(ci\))|(\(cig\))/i' => 'smoking', '/(\(drunk\))/i' => 'drunk', '/(\(bandit\))/i' => 'bandit', '/(\(toivo\))/i' => 'toivo', '/(\(rock\))/i' => 'rock', '/(\(headbang\))|(\(banghead\))/i' => 'headbang', '/(\(bug\))/i' => 'bug', '/(\(fubar\))/i' => 'fubar', '/(\(poolparty\))/i' => 'poolparty', '/(\(swear\))/i' => 'swear', '/(\(tmi\))/i' => 'tmi', '/(\(heidy\))/i' => 'heidy', '/(\(malthe\))/i' => 'malthe', '/(\(tauri\))/i' => 'tauri', '/(\(priidu\))/i' => 'priidu' ); foreach($emotes as $command => $image) $source = preg_replace($command, '[emote]images/smilies/skype/'.$image.'.gif[/emote]', $source); return $source; } function show_emoticons() { $emotes = array( ':)' => 'smile', ':(' => 'sadsmile', ':D' => 'bigsmile', '8)' => 'cool', ':O' => 'wink', ';(' => 'crying', '(sweat)' => 'sweating', ':|' => 'speechless', ':*' => 'kiss', ':P' => 'tongueout', ':$' => 'blush', ':^' => 'wondering', '|-\\' => 'sleepy', '|(' => 'dull', '(inlove)' => 'inlove', '>:)' => 'evilgrin', '(talk)' => 'talking', '(yawn)' => 'yawn', ':&' => 'puke', '(doh)' => 'doh', ':@' => 'angry', '(wasntme)' => 'wasntme', '(party)' => 'party', ':S' => 'worried', '(mmm)' => 'mmm', '8-|' => 'nerd', ':X' => 'lipssealed', '(hi)' => 'hi', '(call)' => 'call', '(devil)' => 'devil', '(angel))' => 'angel', '(envy)' => 'envy', '(wait)' => 'wait', '(bear)' => 'bear', '(makeup)' => 'makeup', '(giggle)' => 'coveredlaugh', '(clap)' => 'clapping', ':?' => 'thinking', '(bow)' => 'bow', '(rofl)' => 'rofl', '(phew)' => 'whew', '(happy)' => 'happy', '(smirk)' => 'smirking', '(nod)' => 'nodding', '(shake)' => 'shaking', '(punch)' => 'punch', '(emo)' => 'emo', '(y)' => 'yes', '(n)' => 'no', '(handshake)' => 'handshake', '(skype)' => 'skype', '(h)' => 'heart', '(u)' => 'brokenheart', '(e)' => 'mail', '(f)' => 'flower', '(rain)' => 'rain', '(sun)' => 'sun', '(clock)' => 'clock', '(8)' => 'music', '(movie)' => 'movie', '(phone)' => 'phone', '(coffee)' => 'coffee', '(pizza)' => 'pizza', '(cash)' => 'cash', '(muscle)' => 'muscle', '(cake)' => 'cake', '(beer)' => 'beer', '(d)' => 'drink', '(dance)' => 'dance', '(ninja)' => 'ninja', '(*)' => 'star', '(mooning)' => 'mooning', '(finger)' => 'finger', '(smoking)' => 'smoking', '(drunk)' => 'drunk', '(bandit)' => 'bandit', '(toivo)' => 'toivo', '(rock)' => 'rock', '(headbang)' => 'headbang', '(bug)' => 'bug', '(fubar)' => 'fubar', '(poolparty)' => 'poolparty', '(swear)' => 'swear', '(tmi)' => 'tmi', '(heidy)' => 'heidy', '(malthe)' => 'malthe', '(tauri)' => 'tauri', '(priidu)' => 'priidu' ); $html = '<a href="#" name="emotes" id="showhide">Toggle Emotes</a><br /><div class="emoticon-list" id="emotes" style="display:none;">'; foreach($emoticons as $short_code => $short_html) $html .= '<img src="images/smilies/skype/' . $short_html . '.gif" data-short-code="' . $short_code . '" />&nbsp;'; $html .= '</div><br /><a href="bbcode.php">Chat Commands</a>'; $js1 = "<script language=\"JavaScript\" type=\"text/javascript\"> <!-- function insertTextAtCursor(el, text) { var val = el.value, endIndex, range, doc = el.ownerDocument; if (typeof el.selectionStart == 'number' && typeof el.selectionEnd == 'number') { endIndex = el.selectionEnd; el.value = val.slice(0, endIndex) + text + val.slice(endIndex); el.selectionStart = el.selectionEnd = endIndex + text.length; } else if (doc.selection != 'undefined' && doc.selection.createRange) { el.focus(); range = doc.selection.createRange(); range.collapse(false); range.text = text; range.select(); } } //--> </script>"; $js2 = "<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.8.3.min.js\"></script>"; $js3 = "<script type=\"text/javascript\"> jQuery(document).ready(function() { jQuery('div.emoticon-list img').click(function() { var jThis = jQuery(this), jMessage = jQuery('input#message'); jMessage.val(jMessage.val() + ' ' + jThis.attr('data-short-code')); }); }); </script>"; $js4 = "<script> var iframeWin = document.getElementById('message').contentWindow; var textObj = iframeWin.document.getElementById('message'); insertTextAtCursor(textObj, jThis.attr('data-short-code')); </script>"; $js5 = "<script> $(document).ready(function(){ $('#showhide').click(function(){ $('#emotes').toggle('slow'); }); }); </script>"; $css = '<style type="text/css"> div.emoticon-list { padding: 5px; border: none; } div.emoticon-list img { cursor: pointer; margin-right: 3px; border: none; width: 20px; height: 20px; } div.emoticon-list img:hover { border: 1px solid #003F87; } </style>'; echo $js5, $html, $css, $js1, $js2, $js3, $js4; } ?> <?php $complete = 1; ?> <?php echo emote(":)");

preferences:
33.23 ms | 402 KiB | 5 Q