Need help to break lines in this script:

Discussion in 'PHP' started by fakestar, Apr 18, 2007.

  1. #1
    Hello, i need help to improve this script, i don't know how to break lines.
    When i press "Create" button, if the phrase is too long...they escape from the image.

    So i need:

    1. break lines
    2. Limit the width of phrase and automatic break lines into width of image.

    online: http://rflmao.info/

    
    
    <form method="post">
    <textarea name="user" cols="80" rows="5" class="textbox">
    Text
    
    It doesn't break
    
    lines
    </textarea>
    <input type="submit" class="button" value="Create">
    <input type="image" border="0" width="500" height="410" src="write.php?caption=<?php echo $_REQUEST['user'] ?>">
    </form>
    
    Code (markup):
    And the script:

    
    <?php
    header("Content-type: image/jpeg");
    //$user = $_POST['caption'];
    $user = $_GET['caption'];
    $im = imagecreatefromjpeg("imagem.jpg");
    $user_width = imagettfbbox(9, 3, "tahoma.ttf", $user);
    $x_value = (250 - ($user_width[2] + 113));
    $color = imagecolorallocate($im, 0, 0, 0);
    imagettftext($im, 25, 0, $x_value, 58, $color, "tahoma.ttf", $user);
    imagejpeg($im);
    imagedestroy($im);
    ?>
    
    Code (markup):

    Any help is welcome, i'm new in php.
    Thanks!
     
    fakestar, Apr 18, 2007 IP
  2. chuckd1356

    chuckd1356 Active Member

    Messages:
    770
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    70
    #2
    chuckd1356, Apr 18, 2007 IP