#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15
    I want to get some small string elements from a long string. The long string are formed by the string elements. The long string are get from MySQL.

    A long string: "B-BO2", "B1TT1", "B-V-TT2".

    string elements:
    "B","B1","B2","B-",
    "BO","BO1","BO2","BO-",
    "V","V1","V2","V-",
    "TT","TT1","TT2","TT-"......

    How to solve it?


    [This message has been edited by RayRay (edited July 14, 2000).]
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    RayRay,

    You are not saying what is the criteria for splitting this string...


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15
    Shiju Rajan,

    The long string is formed by elements. Now, I want to get all elements from a long string.

    string elements list:
    'B', 'B1', 'B2', 'B-',
    'BO', 'BO1', 'BO2', 'BO-',
    'V', 'V1', 'V2', 'V-',
    'TT', 'TT1', 'TT2', 'TT-'......


    For example:
    long string 1: 'B-BO2'.
    result: 'B-', 'B02'.

    long string 2: 'B1TT1'.
    result: 'B1', 'TT1'.

    long string 3: 'B-V-TT2'.
    result: 'B-', 'V-', 'TT2'.

    Please help me, thanks!
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    i wrote most of the solution to this. see the example, and the source

    ------------------

    - weeder

    [This message has been edited by weeder (edited July 16, 2000).]
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    weeder,
    very nice code!!!

    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    thanks

    ------------------
    - weeder
  12. #7
  13. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15
    The elements is stored in a lookup table. It can add / edit / delete the elements by users, so I can't tell you how many elements there. If I hard code in a program, it doesn't work.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    mysql_connect("localhost", "username", "password")
    or die("unable to connect to database");

    $result = mysql_db_query("databasename", "SELECT element_list FROM tablename");

    while(list($key) = mysql_fetch_array($result))
    $element_list[] = $key;
    [/code]

    mysql isn't my speciality, but basically this will assume each row in element_list is an element, and add it to the array $element_list, which you can then use in place of find_element()'s $element_list, and away you go!

    ------------------
    - weeder
  16. #9
  17. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    Hong Kong
    Posts
    71
    Rep Power
    15
    Thank you!

    [This message has been edited by RayRay (edited July 17, 2000).]

Similar Threads

  1. Problem loading XML string
    By peasfood in forum XML Programming
    Replies: 4
    Last Post: February 13th, 2004, 08:04 AM
  2. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  3. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 10:56 AM
  4. mgetty+sendfax on RH9
    By ayrin in forum Linux Help
    Replies: 0
    Last Post: January 31st, 2004, 02:11 AM
  5. split string with irregular space patern
    By sampah95 in forum PHP Development
    Replies: 1
    Last Post: January 29th, 2004, 11:49 AM

IMN logo majestic logo threadwatch logo seochat tools logo