Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.