problem insert values into table using tokenizer..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chennaibala
    New Member
    • Sep 2009
    • 2

    problem insert values into table using tokenizer..

    hi frds...
    in my hiden textbox.i have following values...
    robert|true|tru e|false|arun|tr ue|false|true|a nu|true|true|fa lse|

    i want to splits in to token and insert in mysql table in following manner

    namefield writefiled readfield speakfield
    robert true true false
    arun true false true
    anu true true false

    thanks in advance...
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    best way is to split the string with its delimiter (in your case the bar) then loop through each value. If the value is not true or false, store it in an array as the key (save this value) the next iterations (the true and false values) will be stored under this key so you'll have:

    $array[robert] = array(true, true, false);
    $array[arun] = array(true, false, true);

    so on and so forth

    next loop this array taking the key and values (hint: use a foreach with key and value extracted and use implode to glue the true/false values back together with a comma or whatever format you need it in.

    PMed you the code I posted and got deleted by Atli.

    I knew he's trying to prevent copy/paste solutions in the forum, but this was so simple that it was better to code it than explain it.

    Besides, if you're at this point, you had had to know the basics of programming (arrays, loops, variables) to continue finishing the rest of the program.

    Good luck,



    Dan

    Comment

    Working...