PHP str_replace function

0 Robert Summers · October 19, 2014

<?php

$mystring = "Hello World, I am Robert";
echo 'My string = '.$mystring.'<hr/>';
echo '' .$mystring. '' str_replace('World', 'everybody', $mystring);

?>



How do I get this code to print out


My string = Hello World, I am Robert
_________________________________________

My string = Hello everybody, I am Robert




Thanks for your help in return

Kind regards 
Robert

Post a Reply

Replies

Oldest  Newest  Rating
0 Phillip Drake · October 20, 2014
Robert, I hope this helps you out.  You need to replace the second echo with the following code:


echo 'My string = ' . str_replace( 'World', 'everybody', $mystring);
0 Soyuj Basnet · October 20, 2014
<?php

$mystring = "Hello World, I am Robert";

echo 'My string = '.$mystring.'<hr/>';

echo 'My string = ' . str_replace( 'World', 'everybody', $mystring);


?>
  • 1

PHP

107,016 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators