Jump to content

Recommended Posts

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 :), ;), :D 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 :D

Link to comment
https://forums.phpfreaks.com/topic/208842-convert-text-to-image-php/
Share on other sites

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 =]

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.