Hosting Solutions
mobile_logo Table of Contents

Replace Characters with Emoticon Icons Array Tutorial

Learn to use PHP to change character sequences into emoticons or icons by using the str_replace function. You will want to alter the string data as it comes out of the MySQL database for display, not when the data is being inserted into the database. <?php $db_str = "Show me some <3 right now. It is raining today [umbr], that gives me peace [peace]."; echo $db_str; echo "<hr />"; $chars = array("<3", "[peace]", "[umbr]"); $icons = array("&#10084;", "&#9774;", "&#9730;"); $new_str = str_replace($chars,$icons,$db_str); echo $new_str; ?>

PHP Videos

Array Programming

Dynamic Grid Output Programming Array Data TutorialReplace Characters with Emoticon Icons Array TutorialRandom Array Items From Flat Text File Database TutorialBad Word Filter Function and Harmful Character String Array ReplaceFind Value in Array Search Needle in Haystack TutorialMultiple Files Simultaneous Upload Array Programming TutorialBrowser and Operating System Detect Array Script