Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php strip url of all invalid characters

//replaces all invalid characters in a url with "-"
function url($url) {
   $url = preg_replace('~[^pL0-9_]+~u', '-', $url);
   $url = trim($url, "-");
   $url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
   $url = strtolower($url);
   $url = preg_replace('~[^-a-z0-9_]+~', '', $url);
   return $url;
}
//usage:
$invalidURL = "https://example.com/~+test;
$validURL = url($invalidURL);
Comment

PREVIOUS NEXT
Code Example
Php :: uft8 json php 
Php :: laravel date format valdiate 
Php :: laravel hash password sample 
Php :: laravel queue work schedule cpanel 
Php :: Add button next to "ADD TO CART" on product archive 
Php :: remove cache from page hummingbird 
Php :: Regullar date format for php 
Php :: php file iterator 
Php :: How do I display logged-in username IF logged-in? site:wordpress.stackexchange.com 
Php :: wpmu create user 
Php :: static function php 
Php :: cara install php7.3 di ubuntu 20.04 
Php :: laravel self 
Php :: recursive directory only listing php 
Php :: php draw line pixel 
Php :: yii2 active data provider 
Php :: php command line check syntax errors 
Php :: laravel make model controller and migration one time 
Php :: php fpdf in phpmailer 
Php :: mysql between all months days even null 
Php :: no sass folder in laravel 
Php :: isset in php 
Php :: how to define a function in scheme 
Php :: how to fetch associate data from csv in php 
Php :: php strftime year 2 digits 
Php :: laravel edit method 
Php :: difference between array_merge and + 
Php :: laravel faker value or null 
Php :: iqbal Laravel save record in two table in one line 
Php :: get ids from object 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =