Sat, 18 May 2024


How to remove symbols which are not digits from a string?

By: Anton, NetArt Media
Mon, 28 March 2022

In order to do this you may use the following regular expression:

<?php
....
$strOutput = ereg_replace("[^[:digit:]]", "", $strInput);
...
?>

In this case for example if Input is 43~34^67, the output will be:
433467


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox