rrdtool
+ Reply to Thread
Results 1 to 3 of 3

Thread: [PHP] Need help with Multi-Word Definer

  1. #1
    Join Date
    Sep 2006
    Posts
    1,649

    [PHP] Need help with Multi-Word Definer

    Here is the code
    [PHP]<?php

    /* If there is POST data */
    if (isset($_POST['definetextarea'])) {
    /* Getting input and splitting it by word, counting elements in array */
    $theunexplodedwords = htmlentities($_POST['definetextarea']);
    $theexplodedwords = explode("\n", $theunexplodedwords);
    $fatso = count($theexplodedwords);

    /* Making a loop to define the words, getting the file contents of dictionary.com */
    for ($skinny=0;$skinny<$fatso;$skinny++) {
    $url = "http://dictionary.reference.com/browse/$theexplodedwords[$skinny]";
    $x = file_get_contents($url);

    /* Exploding the stuff before and after the first definition, in order to
    isolate the definition, proceeding to echo the definition */
    $y = explode("<table class=\"luna-Ent\"><tr><td valign=\"top\" class=\"dn\">*.</td><td valign=\"top\">", $x);
    $definition = explode(" </td></tr></table>", $y[*]);
    echo "$theexplodedwords[$skinny] - $definition[0] <br>";
    }

    } else {

    /* Echoing the HTML form if no POST data is detected */
    echo <<<HTMLONE
    <html>
    <head><title>Multi-Word Definer</title></head>
    <body>
    <p align='center'>
    Type in one word per line.
    <br>
    The Multi-Word Definer will define each word.
    <br>
    The definitions are from <a href="http://dictionary.reference.com/">Dictionary.com</a>.
    <form name='defineform' action='$PHP_SELF' method='POST'>
    <center><textarea name='definetextarea' rows='*0' cols='20'>Enter words here</textarea></center>
    <center><input type='submit' value='Define!'></center>
    </form>
    </p>
    </body>
    </html>
    HTMLONE;
    }
    ?> [/PHP]
    The problem is that I can only define one word, and when I try multiple words it doesn't work correctly. Can anyone help me?
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  2. #2
    Join Date
    Sep 2006
    Posts
    1,649
    I'm using newlines (\n)
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  3. #3
    Join Date
    Sep 2006
    Posts
    1,649
    Well, here's some I/O

    Code:
    Input
    test
    
    Output
    test - the means by which the presence, quality, or genuineness of anything is determined; a means of trial. 
    
    ----------------------------------------------
    
    Input
    test
    cheese
    
    Output
    test -
    cheese - the curd of milk separated from the whey and prepared in many ways as a food. 
    
    -----------------------------------------------
    
    Input
    test
    cheese
    (I pressed Enter after 'cheese' leaving this line empty)
    
    Output
    test -
    cheese -
    -
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

+ Reply to Thread

Similar Threads

  1. Regular expression to get multi line comment
    By lissa in forum Programming
    Replies: 0
    Last Post: 06-14-2009, 07:03 AM
  2. Multi-engine virus scanners
    By MrByte in forum Viruses and Trojans
    Replies: 0
    Last Post: 06-05-2008, 12:32 PM
  3. Word list
    By Snowe in forum Programming
    Replies: 6
    Last Post: 10-07-2007, 05:47 AM
  4. D Word to Actual IP in (IRC)
    By Unregistered in forum Internet Privacy
    Replies: 10
    Last Post: 10-05-2004, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts