Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to remove numbers from a String in PHP?

$
0
0

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. ?>

Viewing all articles
Browse latest Browse all 178

Trending Articles