/ PHP

Previous Article

PHP Filename Friendly Function

Next Article

This function outputs a string that is filename friendly. It removes all non-characters and punctuation from the input and converts to lowercase. I find this useful for seo friendly cms pages. This function is still being tweaked so any improvements would be most appreciated.

function checkCharacters($title) {
    $final_text = ”;
    $title = strtolower(trim(stripslashes($title)));
    for ($i = 0; $i < strlen($title); $i++) {
        $letter = substr($title,$i,1); 
        $ascii = ord($letter); 
        if (($ascii >= 97 && $ascii <= 122) || ($ascii>=48 && $ascii <= 57))
        {
            $final_text .= $letter; 
        }
        else 
        {
            $final_text .= "-"; 
        }

    return $final_text;
}
Avatar of Clive Walkden

Clive Walkden

Latest Articles

Linux

Output All Users Cron Jobs

If you want to check all users cron jobs this little command will output them to the command line

Magento 2

Magento 2 admin password history reset

Do you want to clear the password history on your staging test site (not recommended for live)?

Linux

How to see files changed on a certain date

As a sysadmin you often need to see which files have been modified on a certain date.