FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » ampersand help
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
ampersand help [message #175311] Sat, 03 September 2011 01:00 Go to next message
bob is currently offline  bob
Messages: 11
Registered: February 2011
Karma: 0
Junior Member
Can someone tell me why this line of code doesn't work for replacing
an ampersand?

$newstring = str_replace("&", "and", $newstring);
Re: ampersand help [message #175312 is a reply to message #175311] Sat, 03 September 2011 02:59 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/2/2011 9:00 PM, bob wrote:
> Can someone tell me why this line of code doesn't work for replacing
> an ampersand?
>
> $newstring = str_replace("&", "and", $newstring);

Works just fine here. What's in $newstring, both before and after the call?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: ampersand help [message #175319 is a reply to message #175311] Sun, 04 September 2011 14:53 Go to previous messageGo to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:7a650168-4b19-4033-b73d-3e96d33ce531(at)h6g2000yqe(dot)googlegroups(dot)com,
bob <bob(at)coolgroups(dot)com> typed:
> Can someone tell me why this line of code doesn't work
> for replacing an ampersand?
>
> $newstring = str_replace("&", "and", $newstring);

Yes, but you'd do better to go get "The PHP Manual" on PHP and learn that
and a lot more for yourself.

HTH,

Twayne`
Re: ampersand help [message #175320 is a reply to message #175311] Sun, 04 September 2011 20:55 Go to previous message
A is currently offline  A
Messages: 17
Registered: June 2011
Karma: 0
Junior Member
> Can someone tell me why this line of code doesn't work for replacing
> an ampersand?
> $newstring = str_replace("&", "and", $newstring);

There is no problem in that particular line. Perhaps the problem is
elsewhere for example in initialization of $newstring ?

What exactly are you trying to do? And what is the content of $newstring?

Maybe a dumb question but are you trying to do this instead?
$newstring = str_replace("&", "&amp;", $newstring);
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Newbie: very basic jquery drag drop
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 09 08:47:06 GMT 2024

Total time taken to generate the page: 0.03036 seconds