Chris Shiflett wrote:

--- Reuben D. Budiardja wrote:


I did strive for that. But whatever character I choose, the problem
remains that we can't guarantee that it's going ot be only used as
deliminater, since the deliminated string is an input from user. So
the problem remains.



Well, just to point out, your delimiter can be anything, including:


)[EMAIL PROTECTED]&*(donotusethisstringofcharactersinanything(*&[EMAIL PROTECTED])

Of course, at some point, that method of playing with probability becomes
unrealistic, and it is imperfect.

John's suggestion of URL encoding is likely your best bet. Given your string:

$foo:$bar:$blah

Make that instead:

urlencode($foo) . '&' . urlencode($bar) . '&' . urlencode($blah)

Then you can use & as your delimiter and be guaranteed that it does not exist
within each string. It is also easy to recover the original strings, and since
you are using PHP functions, there is less code to write (always a big plus).

Hope that helps.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/



I like the way you encode things like $ in php.

$ = delimiter
/$ = $
//$ = /delimiter
///$ = /$
////$ = //delimiter
/////$ = //$
etc.
//// = //
/$/$ = $$
etc.

To encode the input, just change every / to a // and every $ to a /$. Decoding is the opposite. I don't think that there are any weird situations that can screw this up. You can use the same escape character "/" for any special character, ie /@ or /: if necessary.

Grant





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to