Re: explode and escape character for string separator
| From: | Reuben D. Budiardja | Date: | Fri, 18 Jul 2003 19:56:21 +0000 |
| Subject: | Re: explode and escape character for string separator | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155831@lists.php.net to get a copy of this message | ||
On Friday 18 July 2003 03:33 pm, Chris Sherwood wrote:
> 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
I was thinking about that too, but that doesn't really solve the inherent
problem. What if the user also have "_ " in the string? How then do I know
which "_" is my doing? Because in my case, it's faily conceivable that "_"
will get used.
RDB
> 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.
-------------------------------------------------