Jump to content

How Do I Escape the & Symbol


refiking

Recommended Posts

I have a string that I want to run in a query like this:

$value = Martha_&_Mary_Popserburger;

$newvalue = str_replace('_', ' ', $value);
echo $newvalue;
//$new value keeps getting cut off at Martha 0

 

It's not a string unless it's surrounded by "s.

 

The 'String' should be $value = "Martha & Mary Popserburger";

I have a string that I want to run in a query like this:

$value = Martha_&_Mary_Popserburger;

$newvalue = str_replace('_', ' ', $value);
echo $newvalue;
//$new value keeps getting cut off at Martha 0

 

It's not a string unless it's surrounded by "s.

 

The 'String' should be $value = "Martha & Mary Popserburger";

 

I would encourage 'single quotes' in this case if you truly want the string to be treated exactly like a literal string (also less processing time as you tell PHP you're not including any variables in it):

 

$value = 'Martha & Mary Popserburger';

the $value line isn't in the script.  That was just an example of how it looks.  It's domain.com/Martha_&_Mary_Popserburger/  Where $value = everything between the /'s.  What I want is for the entire value to be present.  Right now, it cuts off at Mary because of the & symbol.  I need the & included

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.