How to Remove Numbers from String in PHP?
Hello Guys,
Now, let's see an example of how to remove numbers from string php. if you want to see an example of php remove all numbers from string then you are in the right place. you will learn php remove numbers from string. you can understand a concept of remove numbers from string php. you will do the following things for remove all numbers from string php.
There are several ways to remove numbers from string value in php. i will give you simple two examples using preg_replace() function. so, let's see the below example.
Example 1: index.php
<?php
$string = "This is a Cars24 Goo23332gle.".
$newString = preg_replace('/[0-9]+/', '', $string);
print($newStrin);
?>
Output:
This is a Cars Google.
Example 2: index.php
<?php
$string = "This is a Cars24 Goo23332gle.".
$newString = preg_replace('/\d/', '', $string);
print($newStrin);
?>
Output:
This is a Cars Google.
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- PHP nl2br() Function Example Tutorial
- PHP Google Recaptcha V2 Example Tutorial
- How to Add Watermark in Image using PHP?
- How to Convert String into Array in PHP?
- How to Subtract Minutes from DateTime in PHP?
- PHP Add Minutes to Time Example
- How to Add Days to Date in PHP?
- How to Upgrade PHP Version from 7.3 to 7.4 in Ubuntu?
- How to Connect SSH using PHP?
- How to Get File Name without Extension in PHP?
- How to Convert Object into Array in PHP?
- MySQL Query to Get Current Month Data Example