Insert text and show images?

Discussion in 'PHP' started by Teunel, Jan 2, 2009.

  1. #1
    Hi,

    I'm looking for a code that does the following:

    When a user inserts a text in an input field, and presses "Submit", it should show images predefined by me for each symbol. Kinda like those Myspace Generators, but I'll use a seperate image for each symbol, and it should generate a HTML code too.

    So, for example, a user inserts: Good morning
    and it should display the following:
    etc. etc.

    Is this easy to achieve, or are there similar scripts available? I'm willing to pay if it does exactly what I need, but it would be even better when it's free. :)

    Thanks!
     
    Teunel, Jan 2, 2009 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Assuming your text input field is named 'text' and your form method is 'post':

    <?php
    $text = $_POST['text'];
    $images = "";
    
    for($i=0; $i<strlen($text); $i++) {
        $images .= '<img src="' . $text[$i] . '.jpg" />';
    }
    ?>
    PHP:
    Then you just print $images; somewhere or <?=$images?> wherever in your HTML you want the images to go. Make changes as needed.
     
    zerxer, Jan 2, 2009 IP