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; 
            $final_text .= "-"; 

    return $final_text;
Avatar of Clive Walkden

Clive Walkden

Latest Articles

Linux command line tools, installations etc


Terraform Installation

A quick installation guide for Terraform on Ubuntu 18.04

Bitcoin - Cryptocurrency not just for geeks


RollerCoin Intro

An introduction to the RollerCoin site and how you can use it to mine your own coins

Magento 2 Blog Posts

Magento 2

Magento 2.4.x Writing to a Log File

How to log to information to a file in different Magento 2.4.x versions