Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13910 > unrolled thread

str_replace does not like empty quotes

Started byrichard <noreply@example.com>
First post2014-06-19 19:33 -0400
Last post2014-06-24 22:08 +0200
Articles 20 on this page of 37 — 10 participants

Back to article view | Back to comp.lang.php


Contents

  str_replace does not like empty quotes richard <noreply@example.com> - 2014-06-19 19:33 -0400
    Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-19 20:09 -0400
    Re: str_replace does not like empty quotes Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-06-19 20:11 -0400
      Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-19 20:55 -0400
      Re: str_replace does not like empty quotes Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-20 03:23 +0000
      Re: str_replace does not like empty quotes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-20 09:31 +0200
    Re: str_replace does not like empty quotes Arno Welzel <usenet@arnowelzel.de> - 2014-06-20 03:19 +0200
      Re: str_replace does not like empty quotes Arno Welzel <usenet@arnowelzel.de> - 2014-06-20 03:21 +0200
        Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-19 21:33 -0400
          Re: str_replace does not like empty quotes Arno Welzel <usenet@arnowelzel.de> - 2014-06-20 04:06 +0200
            Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-19 22:26 -0400
      Re: str_replace does not like empty quotes richard <noreply@example.com> - 2014-06-19 22:13 -0400
        Re: str_replace does not like empty quotes Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-20 03:26 +0000
        Re: str_replace does not like empty quotes Arno Welzel <usenet@arnowelzel.de> - 2014-06-20 11:01 +0200
          Re: str_replace does not like empty quotes Arno Welzel <usenet@arnowelzel.de> - 2014-06-20 11:02 +0200
            Re: str_replace does not like empty quotes Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-20 15:38 +0000
        Re: str_replace does not like empty quotes Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-20 15:32 +0000
    Re: str_replace does not like empty quotes Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-20 01:59 +0000
    Re: str_replace does not like empty quotes Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-20 03:25 +0000
    Re: str_replace does not like empty quotes Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-20 16:10 +1000
      Re: str_replace does not like empty quotes Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-20 13:48 +0200
        Re: str_replace does not like empty quotes Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-20 15:40 +0000
        Re: str_replace does not like empty quotes Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-22 10:05 +1000
          Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-21 20:08 -0400
            Re: str_replace does not like empty quotes Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-23 09:20 +1000
              Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-22 20:44 -0400
                Re: str_replace does not like empty quotes Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-23 16:33 +1000
                  Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-23 09:07 -0400
                    Re: str_replace does not like empty quotes Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-24 12:34 +1000
                      Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-23 23:07 -0400
                      Re: str_replace does not like empty quotes Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-24 11:12 +0000
                        Re: str_replace does not like empty quotes Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-24 08:01 -0400
    Re: str_replace does not like empty quotes Olaf Schmitt <thesys@gmx.de> - 2014-06-24 08:13 +0200
      Re: str_replace does not like empty quotes Arno Welzel <usenet@arnowelzel.de> - 2014-06-24 10:44 +0200
        Re: str_replace does not like empty quotes Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-24 18:48 +0000
          Re: str_replace does not like empty quotes Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-24 21:53 +0200
            Re: str_replace does not like empty quotes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-24 22:08 +0200

Page 1 of 2  [1] 2  Next page →


#13910 — str_replace does not like empty quotes

Fromrichard <noreply@example.com>
Date2014-06-19 19:33 -0400
Subjectstr_replace does not like empty quotes
Message-ID<1kcemjreijezv$.k2q3x4bl6eoc.dlg@40tude.net>
$a=str_replace($a,"\","");

This generates the error: Unexpected "".

http://www.php.net//manual/en/function.str-replace.php

While here in the manual, they do precisely the same thing!

<quote>
If search and replace are arrays, then str_replace() takes a value from
each array and uses them to search and replace on subject. If replace has
fewer values than search, then an empty string is used for the rest of
replacement values. If search is an array and replace is a string, then
this replacement string is used for every value of search. The converse
would not make sense, though. 
</quote>

[toc] | [next] | [standalone]


#13911

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-06-19 20:09 -0400
Message-ID<lnvu4k$cfl$1@dont-email.me>
In reply to#13910
On 6/19/2014 7:33 PM, richard wrote:
> $a=str_replace($a,"\","");
> 
> This generates the error: Unexpected "".
> 
> http://www.php.net//manual/en/function.str-replace.php
> 
> While here in the manual, they do precisely the same thing!
> 
> <quote>
> If search and replace are arrays, then str_replace() takes a value from
> each array and uses them to search and replace on subject. If replace has
> fewer values than search, then an empty string is used for the rest of
> replacement values. If search is an array and replace is a string, then
> this replacement string is used for every value of search. The converse
> would not make sense, though. 
> </quote>
> 

str_replace() works fine with empty quotes.  That's not your problem.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13912

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2014-06-19 20:11 -0400
Message-ID<J_Kov.32084$LR3.8021@fx28.iad>
In reply to#13910
On Thursday 19 June 2014 19:33, in comp.lang.php, "richard"
<noreply@example.com> wrote:

> $a=str_replace($a,"\","");
> 
> This generates the error: Unexpected "".

Of course it does. You are trying to replace all the strings that match $a
with "\" in an empty string ("").

> http://www.php.net//manual/en/function.str-replace.php
> 
> While here in the manual, they do precisely the same thing!

To quote the webpage:
# str_replace — Replace all occurrences of the search string with the
# replacement string 
# Description
# mixed str_replace ( mixed $search , mixed $replace , mixed $subject 
# [, int &$count ] ) 
# 
# This function returns a string or an array with all occurrences of search
# in subject replaced with the given replace value. 

Note that "search" is the first parameter, "replace" is the second,
and "subject" is the third.

So, your 
  str_replace($a,"\","");
will return a string or array with all occurrences of
  the contents of $a
in
  ""
with the given
 "\"
value


What you apparently want is
  str_replace("\","",$a);

> <quote>
> If search and replace are arrays, then str_replace() takes a value from
> each array and uses them to search and replace on subject. If replace has
> fewer values than search, then an empty string is used for the rest of
> replacement values. If search is an array and replace is a string, then
> this replacement string is used for every value of search. The converse
> would not make sense, though.
> </quote>


-- 
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

[toc] | [prev] | [next] | [standalone]


#13913

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-06-19 20:55 -0400
Message-ID<lo00qn$pmc$1@dont-email.me>
In reply to#13912
On 6/19/2014 8:11 PM, Lew Pitcher wrote:
> On Thursday 19 June 2014 19:33, in comp.lang.php, "richard"
> <noreply@example.com> wrote:
> 
>> $a=str_replace($a,"\","");
>>
>> This generates the error: Unexpected "".
> 
> Of course it does. You are trying to replace all the strings that match $a
> with "\" in an empty string ("").
> 
>> http://www.php.net//manual/en/function.str-replace.php
>>
>> While here in the manual, they do precisely the same thing!
> 
> To quote the webpage:
> # str_replace — Replace all occurrences of the search string with the
> # replacement string 
> # Description
> # mixed str_replace ( mixed $search , mixed $replace , mixed $subject 
> # [, int &$count ] ) 
> # 
> # This function returns a string or an array with all occurrences of search
> # in subject replaced with the given replace value. 
> 
> Note that "search" is the first parameter, "replace" is the second,
> and "subject" is the third.
> 
> So, your 
>   str_replace($a,"\","");
> will return a string or array with all occurrences of
>   the contents of $a
> in
>   ""
> with the given
>  "\"
> value
> 
> 
> What you apparently want is
>   str_replace("\","",$a);
> 
>> <quote>
>> If search and replace are arrays, then str_replace() takes a value from
>> each array and uses them to search and replace on subject. If replace has
>> fewer values than search, then an empty string is used for the rest of
>> replacement values. If search is an array and replace is a string, then
>> this replacement string is used for every value of search. The converse
>> would not make sense, though.
>> </quote>
> 
> 

Lew,

Not quite.  Hint: think escape character...

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13921

FromDoug Miller <doug_at_milmac_dot_com@example.com>
Date2014-06-20 03:23 +0000
Message-ID<XnsA351EDE4A3F94dougmilmaccom@78.46.70.116>
In reply to#13912
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote in news:J_Kov.32084$LR3.8021@fx28.iad:

> On Thursday 19 June 2014 19:33, in comp.lang.php, "richard"
> <noreply@example.com> wrote:
> 
>> $a=str_replace($a,"\","");
>> 
>> This generates the error: Unexpected "".
> 
> Of course it does. You are trying to replace all the strings that match $a
> with "\" in an empty string ("").

I thought you plonked him a couple days ago...

[toc] | [prev] | [next] | [standalone]


#13926

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-06-20 09:31 +0200
Message-ID<3722134.N6cizVAKPx@PointedEars.de>
In reply to#13912
[Cancel & Supersedes]

Lew Pitcher wrote:

> On Thursday 19 June 2014 19:33, in comp.lang.php, "richard"
> <noreply@example.com> wrote:

It is called attribution *line*, _not_ attribution novel.

>> $a=str_replace($a,"\","");
                     '---'
>> This generates the error: Unexpected "".

The *actual* error message is

,----
| $ php -r '$a=str_replace($a,"\","");'
| PHP Parse error:  syntax error, unexpected '"' in Command line code on 
      ^^^^^^^^^^^   ^^^^^^^^^^^^             ^^^
| line 1
`----

with

,----
| $ php -v
| PHP 5.6.0beta4 (cli) (built: Jun 10 2014 16:51:46) 
| Copyright (c) 1997-2014 The PHP Group
| Zend Engine v2.6.0-dev, Copyright (c) 1998-2014 Zend Technologies
|     with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend 
| Technologies
|     with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans
`----

Note the *single-quoted* double-quote in the error message.

> Of course it does. You are trying to replace all the strings that match $a
> with "\" in an empty string ("").

No, he does not.  The *main* error here is a *syntax* error.  I have marked 
the string literal in the statement above (as always, use a fixed-width 
font), so that you can see the trailing <"> better.

Note the *escaped* double-quote in the string literal.  Note where the 
string literal starts and where it therefore ends, which syntax-highlighting 
shows in any decent PHP editor (such as Eclipse PDT).
 

PointedEars
-- 
When all you know is jQuery, every problem looks $(olvable).

[toc] | [prev] | [next] | [standalone]


#13914

FromArno Welzel <usenet@arnowelzel.de>
Date2014-06-20 03:19 +0200
Message-ID<53A38C39.3020405@arnowelzel.de>
In reply to#13910
richard, 2014-06-20 01:33:

> $a=str_replace($a,"\","");
> 
> This generates the error: Unexpected "".
> 
> http://www.php.net//manual/en/function.str-replace.php
> 
> While here in the manual, they do precisely the same thing!

No - they don't!

Use: $a=str_replace($a,"\"","");

Beware of the double quotes, since \ starts an escape - this means, the
meaning of the second quote (") is NOT "end string here".

To make this more clear:


" <- String starts here. \" <- This just ONE character  end here -> "


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

[toc] | [prev] | [next] | [standalone]


#13915

FromArno Welzel <usenet@arnowelzel.de>
Date2014-06-20 03:21 +0200
Message-ID<53A38CB2.3090100@arnowelzel.de>
In reply to#13914
Arno Welzel, 2014-06-20 03:19:

> richard, 2014-06-20 01:33:
> 
>> $a=str_replace($a,"\","");
>>
>> This generates the error: Unexpected "".
>>
>> http://www.php.net//manual/en/function.str-replace.php
>>
>> While here in the manual, they do precisely the same thing!
> 
> No - they don't!
> 
> Use: $a=str_replace($a,"\"","");

Sorry - of course: $a=str_replace("\"","",$a);

Since the order of the parameters is

1) What to search
2) What to replace
3) Where to search in

> Beware of the double quotes, since \ starts an escape - this means, the
> meaning of the second quote (") is NOT "end string here".
> 
> To make this more clear:
> 
> 
> " <- String starts here. \" <- This just ONE character  end here -> "


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

[toc] | [prev] | [next] | [standalone]


#13916

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-06-19 21:33 -0400
Message-ID<lo031j$79o$1@dont-email.me>
In reply to#13915
On 6/19/2014 9:21 PM, Arno Welzel wrote:
> Arno Welzel, 2014-06-20 03:19:
> 
>> richard, 2014-06-20 01:33:
>>
>>> $a=str_replace($a,"\","");
>>>
>>> This generates the error: Unexpected "".
>>>
>>> http://www.php.net//manual/en/function.str-replace.php
>>>
>>> While here in the manual, they do precisely the same thing!
>>
>> No - they don't!
>>
>> Use: $a=str_replace($a,"\"","");
> 
> Sorry - of course: $a=str_replace("\"","",$a);
> 
> Since the order of the parameters is
> 
> 1) What to search 
> 2) What to replace
> 3) Where to search in
> 
>> Beware of the double quotes, since \ starts an escape - this means, the
>> meaning of the second quote (") is NOT "end string here".
>>
>> To make this more clear:
>>
>>
>> " <- String starts here. \" <- This just ONE character  end here -> "
> 
> 

Arno, that will replace the double quotes ("), which doesn't look like
what Richard wants.

But why help him when all he does is insult the same people who try to
help him?  That's exactly why I didn't just give him the answer in the
first place (not to mention the fact he's asked similar questions
before, and has still failed to learn).

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13918

FromArno Welzel <usenet@arnowelzel.de>
Date2014-06-20 04:06 +0200
Message-ID<53A39732.5050107@arnowelzel.de>
In reply to#13916
Jerry Stuckle, 2014-06-20 03:33:

> On 6/19/2014 9:21 PM, Arno Welzel wrote:
>> Arno Welzel, 2014-06-20 03:19:
>>
>>> richard, 2014-06-20 01:33:
>>>
>>>> $a=str_replace($a,"\","");
>>>>
>>>> This generates the error: Unexpected "".
>>>>
>>>> http://www.php.net//manual/en/function.str-replace.php
>>>>
>>>> While here in the manual, they do precisely the same thing!
>>>
>>> No - they don't!
>>>
>>> Use: $a=str_replace($a,"\"","");
>>
>> Sorry - of course: $a=str_replace("\"","",$a);
>>
>> Since the order of the parameters is
>>
>> 1) What to search 
>> 2) What to replace
>> 3) Where to search in
>>
>>> Beware of the double quotes, since \ starts an escape - this means, the
>>> meaning of the second quote (") is NOT "end string here".
>>>
>>> To make this more clear:
>>>
>>>
>>> " <- String starts here. \" <- This just ONE character  end here -> "
>>
>>
> 
> Arno, that will replace the double quotes ("), which doesn't look like
> what Richard wants.

Well - I don't know, what Richard really wants. If it was about removing
backslashes:

$a=str_replace("\\","",$a);

> But why help him when all he does is insult the same people who try to
> help him?  That's exactly why I didn't just give him the answer in the
> first place (not to mention the fact he's asked similar questions
> before, and has still failed to learn).

I don't want to give newbies the impression, that Richard knows, what he
is writing about, when he claims that things he does are exactly shown
like that in the PHP manual ;-)


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

[toc] | [prev] | [next] | [standalone]


#13920

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-06-19 22:26 -0400
Message-ID<lo065c$mnn$1@dont-email.me>
In reply to#13918
On 6/19/2014 10:06 PM, Arno Welzel wrote:
> Jerry Stuckle, 2014-06-20 03:33:
> 
>> On 6/19/2014 9:21 PM, Arno Welzel wrote:
>>> Arno Welzel, 2014-06-20 03:19:
>>>
>>>> richard, 2014-06-20 01:33:
>>>>
>>>>> $a=str_replace($a,"\","");
>>>>>
>>>>> This generates the error: Unexpected "".
>>>>>
>>>>> http://www.php.net//manual/en/function.str-replace.php
>>>>>
>>>>> While here in the manual, they do precisely the same thing!
>>>>
>>>> No - they don't!
>>>>
>>>> Use: $a=str_replace($a,"\"","");
>>>
>>> Sorry - of course: $a=str_replace("\"","",$a);
>>>
>>> Since the order of the parameters is
>>>
>>> 1) What to search 
>>> 2) What to replace
>>> 3) Where to search in
>>>
>>>> Beware of the double quotes, since \ starts an escape - this means, the
>>>> meaning of the second quote (") is NOT "end string here".
>>>>
>>>> To make this more clear:
>>>>
>>>>
>>>> " <- String starts here. \" <- This just ONE character  end here -> "
>>>
>>>
>>
>> Arno, that will replace the double quotes ("), which doesn't look like
>> what Richard wants.
> 
> Well - I don't know, what Richard really wants. If it was about removing
> backslashes:
> 
> $a=str_replace("\\","",$a);
> 
>> But why help him when all he does is insult the same people who try to
>> help him?  That's exactly why I didn't just give him the answer in the
>> first place (not to mention the fact he's asked similar questions
>> before, and has still failed to learn).
> 
> I don't want to give newbies the impression, that Richard knows, what he
> is writing about, when he claims that things he does are exactly shown
> like that in the PHP manual ;-)
> 
> 

I don't think even newbies would consider richard knows what he's doing
here...


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#13919

Fromrichard <noreply@example.com>
Date2014-06-19 22:13 -0400
Message-ID<7heper378zqa.dovihixf4du2.dlg@40tude.net>
In reply to#13914
On Fri, 20 Jun 2014 03:19:53 +0200, Arno Welzel wrote:

> richard, 2014-06-20 01:33:
> 
>> $a=str_replace($a,"\","");
>> 
>> This generates the error: Unexpected "".
>> 
>> http://www.php.net//manual/en/function.str-replace.php
>> 
>> While here in the manual, they do precisely the same thing!
> 
> No - they don't!
> 
> Use: $a=str_replace($a,"\"","");
> 
> Beware of the double quotes, since \ starts an escape - this means, the
> meaning of the second quote (") is NOT "end string here".
> 
> To make this more clear:
> 
> 
> " <- String starts here. \" <- This just ONE character  end here -> "

That could be the problem as some times the \ shows and some times it
doesn't.
I've tried several combinatiosn, still the \ remains.

As for the technically correct proper order it is
search, replace, subject.

[toc] | [prev] | [next] | [standalone]


#13923

FromDoug Miller <doug_at_milmac_dot_com@example.com>
Date2014-06-20 03:26 +0000
Message-ID<XnsA351EE5CEC0F8dougmilmaccom@78.46.70.116>
In reply to#13919
richard <noreply@example.com> wrote in news:7heper378zqa.dovihixf4du2.dlg@
40tude.net:

> On Fri, 20 Jun 2014 03:19:53 +0200, Arno Welzel wrote:
> 
>> richard, 2014-06-20 01:33:
>> 
>>> $a=str_replace($a,"\","");
>>> 
>>> This generates the error: Unexpected "".
>>> 
>>> http://www.php.net//manual/en/function.str-replace.php
>>> 
>>> While here in the manual, they do precisely the same thing!
>> 
>> No - they don't!
>> 
>> Use: $a=str_replace($a,"\"","");
>> 
>> Beware of the double quotes, since \ starts an escape - this means, the
>> meaning of the second quote (") is NOT "end string here".
>> 
>> To make this more clear:
>> 
>> 
>> " <- String starts here. \" <- This just ONE character  end here -> "
> 
> That could be the problem as some times the \ shows and some times it
> doesn't.
> I've tried several combinatiosn, still the \ remains.
> 
> As for the technically correct proper order it is
> search, replace, subject.

Indeed it is. But that's not what you're doing. And that's why it doesn't work.

[toc] | [prev] | [next] | [standalone]


#13927

FromArno Welzel <usenet@arnowelzel.de>
Date2014-06-20 11:01 +0200
Message-ID<53A3F850.500@arnowelzel.de>
In reply to#13919
richard, 2014-06-20 04:13:

> On Fri, 20 Jun 2014 03:19:53 +0200, Arno Welzel wrote:
> 
>> richard, 2014-06-20 01:33:
>>
>>> $a=str_replace($a,"\","");
>>>
>>> This generates the error: Unexpected "".
>>>
>>> http://www.php.net//manual/en/function.str-replace.php
>>>
>>> While here in the manual, they do precisely the same thing!
>>
>> No - they don't!
>>
>> Use: $a=str_replace($a,"\"","");
>>
>> Beware of the double quotes, since \ starts an escape - this means, the
>> meaning of the second quote (") is NOT "end string here".
>>
>> To make this more clear:
>>
>>
>> " <- String starts here. \" <- This just ONE character  end here -> "
> 
> That could be the problem as some times the \ shows and some times it
> doesn't.
> I've tried several combinatiosn, still the \ remains.
> 
> As for the technically correct proper order it is
> search, replace, subject.

No - it isn't - READ:

<http://www.php.net//manual/en/function.str-replace.php>


str_replace ( $search , $replace , $subject [, int &$count ] )

This function returns a string or an array with all occurrences of
search in subject replaced with the given replace value.


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

[toc] | [prev] | [next] | [standalone]


#13928

FromArno Welzel <usenet@arnowelzel.de>
Date2014-06-20 11:02 +0200
Message-ID<53A3F8A8.4060700@arnowelzel.de>
In reply to#13927
Arno Welzel, 2014-06-20 11:01:

> richard, 2014-06-20 04:13:
> 
>> On Fri, 20 Jun 2014 03:19:53 +0200, Arno Welzel wrote:
>>
>>> richard, 2014-06-20 01:33:
>>>
>>>> $a=str_replace($a,"\","");
>>>>
>>>> This generates the error: Unexpected "".
>>>>
>>>> http://www.php.net//manual/en/function.str-replace.php
>>>>
>>>> While here in the manual, they do precisely the same thing!
>>>
>>> No - they don't!
>>>
>>> Use: $a=str_replace($a,"\"","");
>>>
>>> Beware of the double quotes, since \ starts an escape - this means, the
>>> meaning of the second quote (") is NOT "end string here".
>>>
>>> To make this more clear:
>>>
>>>
>>> " <- String starts here. \" <- This just ONE character  end here -> "
>>
>> That could be the problem as some times the \ shows and some times it
>> doesn't.
>> I've tried several combinatiosn, still the \ remains.
>>
>> As for the technically correct proper order it is
>> search, replace, subject.
> 
> No - it isn't - READ:
> 
> <http://www.php.net//manual/en/function.str-replace.php>
> 
> 
> str_replace ( $search , $replace , $subject [, int &$count ] )
> 
> This function returns a string or an array with all occurrences of
> search in subject replaced with the given replace value.

Sorry... Richard is really confusing to read sometimes - since he did
read the manual but did not use it...


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

[toc] | [prev] | [next] | [standalone]


#13935

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-06-20 15:38 +0000
Message-ID<lo1khp$ap9$2@dont-email.me>
In reply to#13928
On Fri, 20 Jun 2014 11:02:32 +0200, Arno Welzel wrote:

> Sorry... Richard is really confusing to read sometimes - since he did
> read the manual but did not use it...

Nonono - he did actually read the manual, and then he redefined all the 
words it used to some richardian alternatives.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#13934

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-06-20 15:32 +0000
Message-ID<lo1k74$ap9$1@dont-email.me>
In reply to#13919
On Thu, 19 Jun 2014 22:13:00 -0400, richard wrote:

> As for the technically correct proper order it is search, replace,
> subject.

It may be, but you do not get to redefine the terms search, replace and 
subject to mean whatever you think they ought to mean, you have to 
respect the definitions that the documentation uses.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#13917

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-06-20 01:59 +0000
Message-ID<lo04iq$ksu$1@dont-email.me>
In reply to#13910
On Thu, 19 Jun 2014 19:33:56 -0400, richard wrote:

> $a=str_replace($a,"\","");
> This generates the error: Unexpected "".

Yes, it would.
 
> http://www.php.net//manual/en/function.str-replace.php
> While here in the manual, they do precisely the same thing!

No they don't.

To be more specific, nowhere on that page is an example that contains

	/*_precisely the same_*/

code and strings as you have used.

There is a reason that you have been advised in the past to use certain 
functions and best practices instead of trying to reinvent them yourself. 
This is just another example of your persistent refusal to listen to good 
advice biting your arse.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#13922

FromDoug Miller <doug_at_milmac_dot_com@example.com>
Date2014-06-20 03:25 +0000
Message-ID<XnsA351EE33B57B2dougmilmaccom@78.46.70.116>
In reply to#13910
richard <noreply@example.com> wrote in news:1kcemjreijezv$.k2q3x4bl6eoc.dlg@
40tude.net:

> $a=str_replace($a,"\","");
> 
> This generates the error: Unexpected "".
> 
> http://www.php.net//manual/en/function.str-replace.php
> 
> While here in the manual, they do precisely the same thing!

No, they do not. RTFM, RtS.

<quote>
 mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

This function returns a string or an array with all occurrences of search in subject replaced 
with the given replace value. 
</quote>

Now look at what you wrote, and compare it to the description in the manual.

[toc] | [prev] | [next] | [standalone]


#13924

FromGeoff Muldoon <geoff.muldoon@trap.gmail.com>
Date2014-06-20 16:10 +1000
Message-ID<MPG.2e0e7b4b8ab1628fca@news.albasani.net>
In reply to#13910
In article <1kcemjreijezv$.k2q3x4bl6eoc.dlg@40tude.net>, 
noreply@example.com says...
 
> $a=str_replace($a,"\","");
 
Richard:

a) You need to learn to read the documentation syntax order properly, $a 
goes at the end, not the start.

b) Just because you find a hammer, everything doesn't become a nail.  
Please try and use the RIGHT tool for the job.  Do not mindlessly expect 
silver bullets to appear, especially while looking down a barrel.  Do 
some proper research for yourself first.

c) Google PHP stripslashes.

Geoff M

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.php


csiph-web