Advanced Search

Results 1 to 5 of 5

Thread: PHP Parsing Question

  1. #1
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default PHP Parsing Question

    Is the following process possible:

    1. Enter a text string into a form such as:

    "Dynamic Forums. DHTML Scripts for the real world."

    2. Submit the string to a PHP script and store in a variable.

    3. The script parses the text string on the word level.

    4. The script stores each word into a variable such as:

    $word1 = Dynamic
    $word2 = Forum
    $word3 = DHTML
    .
    .
    .
    .
    $word8 = world

    Thanks

  2. #2
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I think I found the answer to my own question. I'll research the explode function.

  3. #3
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Use php explode function

    Hi try this code

    $string_to_parse="word1 word2";
    $parsedarr=explode(" ",$string_to_parse);
    print_r($parsedarr);


    Cheers!!!
    gdhansekar
    http://www.php-web-developer.net/

  4. The Following User Says Thank You to gdhanasekar For This Useful Post:

    rate (04-26-2008)

  5. #4
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    What if I use the results of explode in a conditional select statement, is there a way periods that are at the end of some words? For example in the first post, if I used explode in the sentence, one of the array elements would be [7]=word.

    If I feed this to a conditional select statement using the WHERE clause, it wouldn't find "word." when it should be looking for "word"

  6. #5
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    you mean $word[7] = "world". select 'field' from 'table' where $word[7] == some field value? Sorry, database of course should be table. fixed it now :-)
    Last edited by tfit; 04-26-2008 at 06:52 PM.

Bookmarks

Posting Permissions

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