Peer-reviewed code snippets that anyone can edit
A wiki for useful code snippets
PHP SEO title generator
r3 r4
15
15
        'ú' => 'u', 'ñ' => 'n', 'Ñ' => 'n');
16
16
       
17
17
    $title = strtr($title, $translation_table);
18
18
    $title = strtolower(trim($title)); // lowercase
19
    $title = preg_replace("/([^a-zA-Z0-9_-])/",'',$title); // only keep standard latin letters and numbers, hyphens and dashes
19
    $title = preg_replace("/([^a-zA-Z0-9_-])/",'',$title); // only keep standard latin
20
                                                              letters and numbers, hyphens
21
                                                              and dashes
20
22
   
21
23
    ## 2. check against db (optional)
22
24
    if ($table AND $field)
23
25
    {
~
~
 
46
48
    }
47
49
    return $title;
48
50
}
49
51
/**
50
* Function that appends an increasing number to a string, for example "peter" becomes "peter1" and "peter129" becomes "peter130".
52
* Function that appends an increasing number to a string, for example "peter"
53
* becomes "peter1" and "peter129" becomes "peter130".
51
54
* (To improve, this function could be made recursive to deal with numbers over 99999.)
52
55
*/
53
56
function append_increasing_number($title)
54
57
{
Tags added:
Tags removed: