Reputation: 7916
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.
Upvotes: 0
Views: 1101
Reputation: 32898
This sounds like you have to use strip_tags()
function from PHP.
Upvotes: -1
Reputation: 57911
addslashes()
is a faster but not as universal a solution as serialize()
Upvotes: 0
Reputation: 1795
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.
Upvotes: 4
Reputation: 33759
If you use the PHP serialize functionality, you wouldn't have to worry about escaping.
Upvotes: 3