Re: explode and escape character for string separator

From: Date: Fri, 18 Jul 2003 19:33:50 +0000
Subject: Re: explode and escape character for string separator
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-155829@lists.php.net to get a copy of this message
After reading your problem this is what I think you should do is dont let the user enter the string predelimited have them enter each individual string at which point you can safely search for the delimiter and replace it with the character of your choice "_" is a favorite of mine. then rebuild the string and delimit it yourself Chris ----- Original Message ----- From: "Reuben D. Budiardja" <reubendb@innovativethought.com> To: <php-general@lists.php.net> Sent: Friday, July 18, 2003 11:47 AM Subject: [PHP] explode and escape character for string separator Hi all, Suppose I have a long string like $myStr = "$string1:$string2:$string3"; I can obviously explode them using ":" as the separator. But what if $string1 contains the character ":" by itself? I was thinking, first I am gonna put an escaping character, so I can do something like: $string1 = str_replace(":", "\:", $string1); But that still won't work with explode. So, what can I use instead of explode? Anything simple, and fast? This is a hypothetical situation. The real situation is that I am trying to have a protocol for data sent by client using Flash. But the basic question remains. Thanks for any help. RDB -- ------------------------------------------------- /"\ ASCII Ribbon Campaign against HTML \ / email and proprietary format X attachments. / \ ------------------------------------------------- Have you been used by Microsoft today? Choose your life. Choose freedom. Choose LINUX. ------------------------------------------------- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#155829) next »