tags:

views:

206

answers:

7

I want to convert arrays into storable string formats using a combination of their keys and values bunched together into a serial string delimited by special characters?

But I am also worried that since it is impossible to predict input from a user form, that the input may also contain the characters I have chosen as the delimiters.

Can I implement custom escape sequences to cater for this?

Well the circumstances require that I implement inter-operable, platform independent solutions other than the traditional serialize or json_encode. Most of the times I don't generate the serial, and only have to consume it from external sources.

+3  A: 

User Serialize() or Json_Encode()

Jan Hančič
+3  A: 

If you use the PHP serialize functionality, you wouldn't have to worry about escaping.

Tor Valamo
A: 

hmm.. this sounds like you have to use strip_tags() function from php

streetparade
A: 

addslashes() is a faster but not such universal solution as serialize()

Dan
A: 

Another way is with the WDDX extension.

kiamlaluno
+1  A: 

JSON is an "inter-operable, platform independent solution". Most languages have a way to convert between JSON and some sort of native object.

XML is another option, you could use PHP's SimpleXMLElement, but it will be more work to build up the data than just passing an array to json_encode().

Using a standard format like XML or JSON will be the best way to make sure the data is accessible in various languages, since those languages will already have a way to read the format.

James Socol
A: 

visit: free php tutorial

kumar