<?php echo addcslashes('foo[ ]', 'A..z'); // output: foo[ ] // All upper and lower-case letters will be escaped // ... but so will the []^_` ?>