Jump to content

Convert text to image [php]


JonnySnip3r

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.