Search
 
SCRIPT & CODE EXAMPLE
 

PHP

string to lowercase accentuation hyphenated

<?php

/**
 * Converts string to SEO-friendly form (lowercase hyphenated alphanumeric words)
 *
 * @param $string
 * @return string
 */
function seoUrl($string)
{
    // qv stackoverflow.com/questions/11330480, stackoverflow.com/questions/1017599

    $src = 'àáâãäçèéêëìíîïñòóôõöøùúûüýÿßÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝ';
    $rep = 'aaaaaceeeeiiiinoooooouuuuyysAAAAACEEEEIIIINOOOOOOUUUUY';

    // strip off accents (assuming utf8 PHP - note strtr() requires single-byte)
    $string = strtr(utf8_decode($string), utf8_decode($src), $rep);
    // convert to lower case
    $string = strtolower($string);
    // strip all but alphanumeric, whitespace, dot, underscore, hyphen
    $string = preg_replace("/[^a-z0-9s._-]/", "", $string);
    // merge multiple consecutive whitespaces, dots, underscores, hyphens
    $string = preg_replace("/[s._-]+/", " ", $string);
    // convert whitespaces to hyphens
    $string = preg_replace("/[s]/", "-", $string);

    return $string;
}
Comment

PREVIOUS NEXT
Code Example
Php :: php array merge without array_merge 
Php :: https://github.com/nuxt/nuxt.js/issues/8315#:~:text=%3Chtml%20lang%3D%22ru%22%20data%2Dn%2Dhead%3D%22%257B%2522lang%2522%3A%257B%2522ssr%2522%3A%2522ru%2522%257D%257D%22%3E 
Php :: optional route parameter in laravel 
Php :: cara looping abjad with range no kapital 
Php :: Use the DebugBar like an array where keys are the collector names 
Php :: php how to check if user has a role on login 
Php :: wordpress remove noindex programmatically 
Php :: magento 2 add cc transportbuilder 
Php :: converting php to codeigniter 
Php :: Storing login info in a session 
Php :: Code début Selenium PHP 
Php :: Problem getting updated value from child component to the parent component in a Laravel 9 with Vue 
Php :: traduction website with i18n 
Php :: pass messages laravel 
Php :: Array unpacking support for string-keyed arrays - PHP 8.1 
Php :: laravel how to address to git repo for develop packages 
Php :: how to fetch data from two tables in mysqli using php 
Php :: <?php function find total( $my_list ) { //Insert your code here } ? 
Php :: rename image file using post id in wordpress programmatically 
Php :: Adding Conditional Classes to Menu Items 
Php :: Input sanitization to prevent XSS 
Php :: lastPage does not exist. 
Php :: whats is typecasting in php 
Php :: laravel handle image validation 
Php :: omnipay capture 
Php :: PHP OOP - Access Modifiers 
Php :: create newfilter wordpress 
Php :: wordpress get posts by multiple authors 
Php :: sql update views +1 
Php :: Prevent infinite loop when saving Statamic entry 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =