Jump to content

Remove from string


ngreenwood6

Recommended Posts

I tried that but it doesnt seem to be working. Do I need to assign the variable the value of str_replace like this:

 

$string = "This is a test";
$string = str_replace($string, "", "test");

 

You got the argument order wrong:

$string = "This is a test";
$string = str_replace('test', '', $string);

 

EDIT - On that note, if your IDE has code hint / completion capabilities, you can always make use of that in the event you are unsure of which order what goes into...

Link to comment
https://forums.phpfreaks.com/topic/156934-remove-from-string/#findComment-826656
Share on other sites

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.