irwan

extract numbers from string / word

Nov 15th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.26 KB | None | 0 0
  1. <?php
  2.  
  3. $string = "The 1. Quick and 2. Brown fox said 3. (!@*(#!@*";
  4.  
  5. $new_string = ereg_replace("[^0-9]", "", $string);
  6.  
  7. echo $new_string;
  8.  
  9. ?>
  10.  
  11.  
  12. <?php
  13. $Test1 = "<b> tebel</b> ";
  14. $Test2 = preg_replace("/[^a-zA-Z0-9\s]/", "", $Test1);
  15. echo $Test2;
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment