Search
 
SCRIPT & CODE EXAMPLE
 

PHP

slug in php

$slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
Comment

create slug with php

public static function slugify($text, string $divider = '-')
{
  // replace non letter or digits by divider
  $text = preg_replace('~[^pLd]+~u', $divider, $text);

  // transliterate
  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

  // remove unwanted characters
  $text = preg_replace('~[^-w]+~', '', $text);

  // trim
  $text = trim($text, $divider);

  // remove duplicate divider
  $text = preg_replace('~-+~', $divider, $text);

  // lowercase
  $text = strtolower($text);

  if (empty($text)) {
    return 'n-a';
  }

  return $text;
}
Comment

PREVIOUS NEXT
Code Example
Php :: php loop through list 
Php :: php include and require statements 
Php :: laravel 8 date difference in days 
Php :: bin to dec php 
Php :: test curl php 
Php :: laravel drop column 
Php :: http error code php 
Php :: wp get field taxonomy 
Php :: get the category wp 
Php :: make a object php 
Php :: sort laravel eloquent 
Php :: php artisan vendor:publish 
Php :: how to upload pdf file using php 
Php :: acf php fields 
Php :: set default value for column in laravel model 
Php :: convert date php 
Php :: optimize clear laravel not working 
Php :: publish Laravel mail pages to customize 
Php :: php artisan storage link cpanel 
Php :: laravel wherehas with condition 
Php :: logout in php 
Php :: e_notice in php 
Php :: concat function using laravel update query 
Php :: ubuntu install lamp and phpmyadmin 
Php :: redirect back with input laravel in request 
Php :: laravel composer update 
Php :: session variable in laravel 
Php :: php show active page 
Php :: check if a string contains a substring in php 
Php :: hmtl remove tag php 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =