simple function to remove non numeric characters from a string with PHP

stripNonNumeric.php

<?php
/*
  Remove non-numeric characters from a string.
*/
function stripNonNumeric($str='') {
  return preg_replace('(\D+)', '', $str);
}
?>

Refer gist for comments https://gist.github.com/justinkelly/953216

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP, ReactJS, Tableau, AWS RedShift and Matillion ETL

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Leave a comment

Name Notify me of replies by email.