If you have a blog in which you’d like to use the title of your entries in the URL, you need to convert them to URL slugs. CodeIgniter’s built-in library offer a method to help us with this task.
URL Helper is a library which assists in working with URLs. You can use this helper’s methods retrieve data or format URL such as getting application’s base URL/domain and printing a link with anchor.
In this post, we will talk about
url_title, which takes a string as input and creates a human-friendly URL string.
url_title($str, $separator = '-', $lowercase = FALSE)
|Parameters:||$str (string) – Input string|
$separator (string) – Word separator
$lowercase (bool) – Whether to transform the output string to lower-case
$title = "Convert title to URL slug in CodeIgniter"; $url_title = url_title($title, '-', true); //output: convert-title-to-url-slug-in-codeigniter