Reputation: 287
I have a multi dimensional array i want to convert this array to string and saved in to a file.Also need to convert string that stored in the file to the previous array for further processing. (i.e the file is like a table in the database ). Is it possible to convert the array to string and then back to array using php? If anyone knows please help me thanks in advance...
Upvotes: 1
Views: 1533
Reputation: 81988
serialize
converts a PHP object to a string. unserialize
converts that string into whatever it was stored as. Also see __sleep
and __wakeup
.
Upvotes: 2
Reputation: 19385
You can also use the built-in seralize
function that will serialize any type of data.
Upvotes: 1
Reputation: 85
i think you have to loop through this array manually to build your string for your purpose. You can use the php function implode for a onedimensional array.
Read the comments of http://php.net/manual/en/function.implode.php .There is an algorithm to get this done also usinhg the implode function.
Upvotes: -1