Filtering Of URL : Make Text url-safe
URL filtering is important: everyone from marketers to search engines loves nice, text-rich URLs. If we want to create keyword-rich URLs based on our dynamic content then we will need to clean and filter the source text first. Here is a handy function that will generate text very much. We can use this pretty much anywhere like in tagging systems, and in code that creates permalinks based on post titles or taxonomy terms. function filter($value, $force_lower_case = true) { if ($force_lower_case) { $value = strtolower($value); } // remove everything except A-Z, a-z, 0-9, hyphens, and whitespace $value = preg_replace( "/[^a-zA-Z0-9-\s]/", '', $value ); // convert whitespaces to hyphens $value = preg_replace( "/\s/", '-', $value ); // replace multiple hyphens with a single hyphen $value = preg_replace( "/[-]+/", '-', $value ); return $value; } Note: This is a secure appro...