Remove All Non-Numeric Characters from String using PHP

preg_replace function

<?php

$text = 'Number: +(123) 726-632';
$result = preg_replace('/\D/', '', $text);

echo $result;

Leave a Comment

Cancel reply

Your email address will not be published.