Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Slug {
- public function create_slug($slug, $table)
- {
- $CI =& get_instance();
- $CI->load->helper('url');
- $CI->load->helper('text');
- $CI->load->database();
- $slug = strtolower(url_title(convert_accented_characters($slug)));
- $query = $CI->db->query("SELECT * FROM $table WHERE slug = '$slug'");
- $count = $query->num_rows();
- if ($count == 1 ) {
- do
- {
- $count++;
- $slug .= '-'.$count;
- } while ($count == 0);
- }
- return $slug;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement