Breaking News
Home / Web / PHP / PHP Snippets / How to remove numbers from a String in PHP?

How to remove numbers from a String in PHP?

Snippet

  1. <?php
  2. function cleanup_numbers($string) {
  3.   $numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
  4.   $string = str_replace($numbers, , $string);
  5.   return $string;
  6.  }
  7.  
  8.    $username=‘jamrod12345’;
  9.   // will print jamrod
  10.    echo cleanup_numbers($username);
  11.        
  12. ?>
[pb_builder]

Check Also

How to list files in a directory in PHP?

<?php if ($handle = opendir(‘/path/to/directory’)) {     echo "Directory handle: $handlen";     echo …

Advertisment ad adsense adlogger