Php-How to make slug in php

## make slug using this function. Like: stackofcodes.in/2016/01/10/how-to-search-data-from-table-in-php/ function makeslug($str) {     return preg_replace(“/[^0-9a-zA-Z]+/”, “-“, $str); } $tog = how_can i make slug. $slug = function makeslug($tog); Example: Its Look Like: how-can-i-make-slug  

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+/’, ‘ ‘, $data_slug); $data_slug1 = trim($data_slug1); $data_slug2 = str_replace(” “, “-“, $data_slug1); echo $data_slug2;