• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

PHP: Strip everything but numbers and letters

Hi All,

How can I strip everything from a variable that isnt a number or letter?


Thanks
0
detox1978
Asked:
detox1978
1 Solution
 
käµfm³d 👽Commented:
You could use preg_replace:

$result = preg_replace('/[^a-zA-Z0-9]/', '', $input);

Open in new window


...where "[^a-zA-Z0-9]" means any character NOT ( [^...] ) a letter ( a-zA-Z ) or number ( 0-9 ).
0
 
detox1978Author Commented:
awesome thanks!
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now