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.

.medrectangle-4-multi-155{border:none!important;display:block!important;float:none!important;line-height:0;margin-bottom:15px!important;margin-left:0!important;margin-right:0!important;margin-top:15px!important;max-width:100%!important;min-height:250px;min-width:300px;padding:0;text-align:center!important}

I hope it can help you…

Leave a Comment