ManyCodes.com – codes & scripts Get free programming codes and tutorials!

13Feb/100

Remove all characters except letters and numbers from a string

If you insert a new value to a MySQL database, and the id is an auto_increment, this simple function will obtain the id for you without having to do a new query on the database. This is the easiest way to get the id from a newly added row using a MySQL insert query without having to do a second query.

<?php
$string = "This is some text and numbers 12345 and symbols !£$%^&";
$new_string = ereg_replace("[^A-Za-z0-9]", "", $string);
echo $new_string
?>



Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Webnews
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Ask
  • Facebook
  • Technorati
  • YahooBuzz