p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   PHP How-To (http://p2p.wrox.com/forumdisplay.php?f=98)
-   -   String to Array (http://p2p.wrox.com/showthread.php?t=47422)

Psion September 5th, 2006 11:12 AM

String to Array
 
I was wondering if there was a way to convert a string back into an array, like say:

$foo = array("vegetable" => "apple", "fruit" => "grape");
$array = print_r($foo, true);
$array = string_to_array($array);
print $array['vegetable'];

It's not difficult to create that for me, but when I get into deep multidimensional arrays I'm lost as to how to develop those loops. I can get all the values fine but everything I can think of won't retain the embedded array's key.


Thanks for any help.


richard.york September 5th, 2006 11:36 AM

You're looking for the serialize and unserialize functions.

http://www.php.net/serialize
http://www.php.net/unserialize

HTH!

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html


All times are GMT -4. The time now is 09:16 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.