July 14th, 2000, 11:54 AM
-
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).]
July 15th, 2000, 03:23 AM
-
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..."
July 15th, 2000, 04:31 PM
-
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!
July 16th, 2000, 02:28 AM
-
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).]
July 16th, 2000, 11:00 AM
-
weeder,
very nice code!!!
------------------
SR -
webshiju.com
"The fear of the LORD is the beginning of knowledge..."
July 16th, 2000, 07:46 PM
-
thanks 
------------------
- weeder
July 16th, 2000, 08:27 PM
-
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.
July 16th, 2000, 09:50 PM
-
<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
July 17th, 2000, 10:47 AM
-
Thank you! 
[This message has been edited by RayRay (edited July 17, 2000).]