Friendly functions URL

It generates urls friendly in php


It creates URL friendly with a simple function programmed in php to personalize any chain of characters in a friendly URL for the finders.


/* TEST * <? =slug (€˜URL title of tests€™)? >/* RESULT * URL-title-of-tests

/** @desc: To create friendly URL @status: STABLE @build: PASSED @version: 0.0.3 @fecha: 15.10.2015 * function slug ($url=NULL) \ {//Rememplazamos Latin special characters $find1 = Array (€˜to€™, €˜and€™, €˜i€™, €˜either€™, €˜or€™, €˜n€™); $repl1 = Array (€˜to€™, €˜and€™, €˜i€™, €˜or€™, €˜or€™, €˜n€™); $url = str_replace ($find1, $repl1, $url); //A ±adimos the scripts $find2 = Array (€˜€˜,€™€™, €˜&€™, €˜\ r \ n€™, €˜\ n€™, €˜+€™); $url = str_replace ($find2, €˜-€™, $url); //Eliminamos and Reemplazamos other special characters $find3 = Array (€˜/[^a-z0-9 \ - <>]/€™, €˜/[\ -] +/€™, €˜/< [^>] *>/€™); $repl3 = Array (€, €˜-€™, ''); $url = str_replace ($find3, $repl3, $url); //Si the last character is a script we cleared it if (! is_array ($url) && substr ($url, -1) == €˜-€™) \ {$url = substr ($url, 0, -1); } return $url; }