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

Posted:

Latest Articles

Magento 2 Releases Evolution - Features, Popularity & Issues

Magento 2

A Comprehensive Guide to Major Releases of Magento 2

Explore the evolution of Magento 2 through its major releases, detailing features added, popularity metrics, and issues encountered.

How to Install NordLayer VPN Client on Ubuntu 20.04 and Connect to a Virtual Network

Linux

How to Install NordLayer VPN Client on Ubuntu 20.04 and Connect to a Virtual Network

A simple to follow installation guide for NordLayer VPN

Mastering MySQL Database Imports on Linux - A Comprehensive Guide

MySQL

Mastering MySQL Database Imports on Linux

Learn efficient ways to import MySQL databases on Linux using the mysql command-line client. Explore the --source option and < operator for seamless data migration. Master MySQL imports on Linux with our comprehensive guide.