This function is very useful. It's called str_replace(). It finds a specified string and replaces it with another in a source string.
<?php
echo str_replace("world","Peter","Hello world!");
?>The output of the code above will be:
Hello Peter!Note: This will find
every instance of the search string and replace them all.
You can also pass arrays as the search and replace variables instead.
These can be used for replacing profanity, creating a BB Code function, or used to create your own variable system. Such as adding a variable that users can use in-game, such as {USERNAME}. Then you just search for the string "{USERNAME}", and replace it with $username
