Wrox Programmer Forums
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 5th, 2006, 11:12 AM
Registered User
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

Old September 5th, 2006, 11:36 AM
richard.york's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts

You're looking for the serialize and unserialize functions.




Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
String to array ajit Javascript 5 January 20th, 2007 04:02 PM
Casting String array to string Samatha ASP.NET 1.0 and 1.1 Professional 1 December 5th, 2006 07:46 AM
Duplicate Array value/string .NETamateur C# 3 November 3rd, 2006 08:58 AM

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