Are you sure you even want to be storing it that way? What happens when you delete the following row? Do you have to re-index each column? There's no (trivially) easy way to do that with an update statement as it stands. vehMdlCd[1] LEX You're likely better off storing it simply as field/value, and storing the numbering in another column if you actually need the number at all. Then you can pull each out and simply $T100s[$row['T100Field']][] = $row['T100Value']; // or equivalent This also gives you the benefit of being able to make a unique key against t100field/t100value to prevent duplicates at your database level. T100Field T100Nm T100Value ========== ========= ========= vehMdlCd 0 MER vehMdlCd 1 LEX vehMdlCd 2 TOY * again, I'd only keep T100Nm around if you need it for sorting purposes, don't use it as an array index, if you do or might even remove rows/etc. and need the array condensed. --- Otherwise I'd just pull each row out, match it to its prefix /(^[^\[]*)[([^\]]*)]/ and make an array out of the result. Still, lots more effort than the separate columns method. cheers, - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -----Original Message----- From: Ng Hwee Hwee [mailto:hhwee@xxxxxxxxxxx] Sent: Thursday, September 29, 2005 10:23 PM To: PHP DB List Subject: Convert String to Array. . Hi guys, this looks like a very simple problem but i really have no idea how to do it.. please help me! thanks! my MySQL database has a table of which 2 fields are as follow T100FieldNm T100Value ========== ========= vehMdlCd[0] MER vehMdlCd[1] LEX vehMdlCd[2] TOY and I need to echo out the value for $vehMdlCd[0]...[2]. but when I retrieve T100FieldNm from the database, PHP recognises it only as a string. Thus, in order to get the value of $vehMdlCd[0], I need to do the following. for($i=0; $i<$numOfRows; $i++) { $tmpVehMdlCd = "vehMdlCd[$i]"; $vehMdlCd[$i] = $$tmpVehMdlCd; } where $numOfRows has been calculated by doing a count of all T100FieldNm like "vehMdlCd%". Can someone enlighten me with a simpler way?! Potentially I can have a 100 over different T100FieldNm! =( I tried using settype and type-casting but still don't get the respective T100Value! *sob* Thanks sooo much! Best regards, Hwee Hwee -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php