Replace strange characters

I have this code:
$sth = $BD->prepare("INSERT INTO table (codigo, nom) VALUES (:codigo, :nom)");
$codigo = "666000";
$nom   = "  mac'p_i¥At"-o   ";

$sth->bindParam(':codigo', $codigo);
$sth->bindParam(':nom', $nom);

$sth->execute();
PHP:
I want to clean my var $nom="macpiñato". First delete blank spaces before and after of value.
Delete too (') and (") and underline (_) and line (-), etc.
How I do that. I read about trim(), str_replace, preg_replace, etc.

from PHP http://ift.tt/1Y6yH5i
via IFTTT
Previous
Next Post »
Thanks for your comment