- Code: Select all
<?php
$string_to_be_stripped = "Hi, I am a string and I need to be stripped...";
$new_string = ereg_replace("[^A-Za-z0-9]", "", $string_to_be_stripped );
?>
Reference: http://www.emanueleferonato.com/2006/07 ... -with-php/
My version:
- Code: Select all
function _clean_input($id) {
$cleaned_input = $this->input->post($id);
if ($cleaned_input !== FALSE) {
$cleaned_input = preg_replace("/[^\w\s-,]/", "", $cleaned_input);
}
return $cleaned_input;
}
Reference: http://us.php.net/manual/en/function.preg-replace.php
