How to make slug removing whitespaces in php

$data = “new & item @ send to & be”; $data_slug = trim($data); //$search = array(‘/’,’\\’,’:’,’;’,’!’,’@’,’#’,’$’,’%’,’^’,’*’,'(‘,’)’,’_’,’+’,’=’,’|’,'{‘,’}’,'[‘,’]’,'”‘,”‘”,'<‘,’>’,’,’,’?’,’~’,’`’,’&’,’ ‘,’.’); $search = array(‘/’,’\\’,’:’,’;’,’!’,’@’,’#’,’$’,’%’,’^’,’*’,'(‘,’)’,’_’,’+’,’=’,’|’,'{‘,’}’,'[‘,’]’,'”‘,”‘”,'<‘,’>’,’,’,’?’,’~’,’`’,’&’,’.’); $data_slug = str_replace($search, ” “, $data_slug); $data_slug1 = preg_replace(‘/\s+/’, ‘ …

How to make slug removing whitespaces in php Read More