Tuesday 1 December 2015

Remove all characters and spaces form string in php

Remove all characters and spaces form string in php


 $string = 'name @123&';
 
echo preg_replace('/[^A-Za-z0-9\-]/', '', $string)