PHP String Replace Only Numbers with Space Example
Hi Dev,
In this tutorial, I will show you php string replace only numbers with space example. I explained simply step by step replace numbers with space in php - string. you will learn php replace numbers with space with code examples. I would like to show you php replace numbers with space.
In this example string numbers with space in PHP. in this example, we will use to preg_replace() function to Replace Numbers with Space. so Let's see following example with output.
Example : String Replace Numbers with Space
index.php
<?php
//create string
$str = "Hello 10 developers welcome to our company's 5 year completed celebration";
//Replace numbers with space
$newStr = preg_replace('/[0-9]+/',' ', $str);
echo $newStr;
?>
Output:
Hello developers welcome to our company's year completed celebration
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