PHP String Replace Last 3 Characters Example
Hi Dev,
This tutorial will give you example of php string replace last three characters example. This article will give you simple example of replace last three characters from string in php. I’m going to show you about php replace last three characters with code examples. I explained simply about how to use function replace last three characters?.
In this example string Replace Last Three Characters in PHP. in this example, we will use to substr() function to replace Last Three Characters. so Let's see following example with output.
Example : String Replace Last 3 Characters
index.php
<?php
// Create string
$str = "Welcome to Nicesnippets.org";
// Replace Last Three Characters
$newStr = substr($str, 0, -3).'com';
echo $newStr;
?>
Output:
Welcome to Nicesnippets.com
I hope it could help you...
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example