1
How can I remove anything other than a letter and number string, that is to remove (!@#$%^&*():"><?}
etc.) and keep only the letters of a-z and numbers of 0-9
1
How can I remove anything other than a letter and number string, that is to remove (!@#$%^&*():"><?}
etc.) and keep only the letters of a-z and numbers of 0-9
1
Just use the str_replace()
.
$chars = array('!', '@', '#');
echo str_replace($chars, '', 'oh! texto com # e @ para apagar!');
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
1
Using the following regular expression:
[^\w]
And make the substitution using preg_replace
:
$texto = 'Ex#em$!plo uti@!lizando r3gex';
echo preg_replace('/[^\w]/', '', $texto);
Browser other questions tagged php string
You are not signed in. Login or sign up in order to post.
You can use several str_replace cascades by substituting "" (empty string). or regular expressions (never tested)
– Ricardo
Can any of the answers be accepted here?
– Maniero