<?PHP

/*////////////////////////////////////////////////////////////////////////////////////////////////
//  This is a simple script using http://www.artypapers.com/csshelppile/pcdtr/            //
//  text to image script.                                    //
//                                                //
//  This script breaks words apart so each letters can be printed invidually            //
//  and if the image is not shown, you'll see the text instead (composed by            //
//  each letters the image was suppose to show.                            //
//                                                //
//  Usage:                                            //
//  INSERT at the beginning of your page in a PHP section                    //
//  Call the texttoimage script                                    //
//  include(text.php);                                        //
//                                                //
//  TO USE:                                            //
//  call the function image() with the text as a parameter.                    //
//  ex. image("I want some coffea");                                //
//                                                //
//  Version 1.0.1 Alpha                                        //
//                                                //
//  Changes:                                            //
//        + Using preg_split instead of str_split for PHP 4.0 compatibility        //
////////////////////////////////////////////////////////////////////////////////////////////////*/


//////////////////////////////////////////////////////////////////////////////////////////////////
//                 CONFIGURATION (ONLY HERE)                    //
//////////////////////////////////////////////////////////////////////////////////////////////////

// script location
$pcdtr "http://www.yourdomain.com/pcdtr/image.php";


//////////////////////////////////////////////////////////////////////////////////////////////////
//                                                //
//                 DO NOT EDIT BELOW THIS POINT !!! >>                //
//                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////
function image($text)
    {
    global 
$pcdtr;
    
//$characters = str_split($text,1);
    
$characters preg_split('//'$text, -1PREG_SPLIT_NO_EMPTY);
    
$i 0;
    while (
$i strlen($text))
        {
        
// translate a space into a space :)
        
$charactera preg_replace "/\s/""%20"$characters[$i] );
        echo 
"<img src=\"" $pcdtr "?text=" $charactera "\" alt=\"" $characters[$i] . "\" >";    
        
$i $i 1;
        }
    }
    
if(!empty(
$_GET['text']))
{
image($text);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//                    END OF THE SCRIPT                    //
//////////////////////////////////////////////////////////////////////////////////////////////////
    
?>