Computing.Net > Forums > Database > Use string stored in db as an array

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Use string stored in db as an array

Reply to Message Icon

Name: KelvinJones
Date: February 25, 2009 at 08:43:46 Pacific
OS: Macintosh
Subcategory: MySQL
Comment:

Hi All,

I'm trying to write a script to generate rows in a table from arrays and sub-arrays.

Its all working lovely but i've come up against a problem... all i want to do is store the full array string in a database then retrieve it to use when its needed, the problem is that the retrieved string just acts as a string and not a set of arrays!!

This is what i'm trying to store, it should be self explanetory...

array(
array("Field1","Field2","Field3","Field4"), array("row1","row1","row1","row1"), array("row2","row2","row2","row2"), array("row3","row3","row3","row3"), array("row4","row4","row4","row4")
)

this generates a 4 x 5 table in the final script but only when it is coded into the PHP as arrays.

$data = array(array("Field... works

$data = $string_from_db doesn't



Sponsored Link
Ads by Google

Response Number 1
Name: KelvinJones
Date: February 26, 2009 at 01:57:53 Pacific
Reply:

Okay sorted it...

Run the array through serialize() in PHP before storing it into the MySQL DB - then when you retrieve it you can unserialize() it and hey-presto its an array again.

Lovely PHP.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Use string stored in db as an array

Fractions in MySQL www.computing.net/answers/dbase/fractions-in-mysql/240.html

MySQL: Storage Engine/Field Type www.computing.net/answers/dbase/mysql-storage-enginefield-type/268.html

Access question www.computing.net/answers/dbase/access-question/69.html