Horje
How to remove all number from a string php

For Western Arabic numbers (0-9):

$words = preg_replace('/[0-9]+/', '', $words);

For all numerals including Western Arabic (e.g. Indian):

$words = '१३३७';
$words = preg_replace('/\d+/u', '', $words);
var_dump($words); // string(0) ""
  • \d+ matches multiple numerals.
  • The modifier /u enables unicode string treatment. This modifier is important, otherwise the numerals would not match.

How to remove all numbers from string? PHP

I'd like to remove all numbers from a string [0-9]. I wrote this code that is working.
index.php
Example: PHP
<?php
$words = '१३३७ 11544 I love';
$words = preg_replace('/\d+/u', '', $words);
var_dump($words);
?>

Output should be:

How to remove all numbers from string? PHP




php remove number from line

Related Articles
How to check if a string contain multiple specific words PHP String Tutorial
How to extract words from Sentence in PHP PHP String Tutorial
How to check if string is_numeric() Function in PHP PHP String Tutorial
How to get only text from HTML Source Code by PHP PHP String Tutorial
How to get first 3 words from a sentence by PHP PHP String Tutorial
How to work if empty value does not else PHP String Tutorial
How to remove first Five Line from a TXT File in PHP PHP String Tutorial
How to get Longest Word from a Sentence in PHP PHP String Tutorial
How to remove first character from string php PHP String Tutorial
How to count if Number is below than 10 sum PHP String Tutorial
How to get back page link PHP String Tutorial
How to get first 3 longest words from a sentence PHP PHP String Tutorial
How to count number of words from sentence in PHP PHP String Tutorial
How to remove all number from a string php PHP String Tutorial
How to create first word Upper/Big from a sentence PHP String Tutorial

Single Articles
How to remove all numbers from string? PHPPHP String Tutorial

Read Full:
PHP String Tutorial
Type:
Develop
Category:
Web Tutorial
Sub Category:
PHP String Tutorial
Uploaded by:
Admin
Views:
85


Reffered: https://stackoverflow.com/questions/14236148/how-to-remove-all-numbers-from-string