JonnySnip3r Posted July 25, 2010 Share Posted July 25, 2010 Hey guys was wondering if someone could help me. Ok i have a set of images smile_face.png, sad_face.png, cry_face.png etc. etc. these are 16px by 16px not that it matters. Is there a pre-built function that can convert say , , etc. to these images? So in the text box it will see these as text however when the user posts it will convert them to images? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/208842-convert-text-to-image-php/ Share on other sites More sharing options...
JonnySnip3r Posted July 25, 2010 Author Share Posted July 25, 2010 No one helped =[ anyways i came up with this any suggestions or would it be done like this, im newish to php (is there only so many times i can get away with that?). SO any improvements would be great!! function convert_string_to_image($string){ switch($string){ case "": $string = "<img src=\"profile/icons/emoticon_smile.png\" alt=\"smile_face\" />"; break; case ""; $string = "<img src=\"profile/icons/emoticon_grin.png\" alt=\"smile_grin\" />"; break; case ""; $string = "<img src=\"profile/icons/emoticon_tongue.png\" alt=\"smile_tongue\" />"; break; } return $string; } i didnt add a default in because if it cant find it then it will just show the text =] Quote Link to comment https://forums.phpfreaks.com/topic/208842-convert-text-to-image-php/#findComment-1090999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.