Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php replace spaces with dash

str_replace(' ', '-', $string);
Comment

php replace space with dash

<?php 
  $string = "hello php";
  $replace = str_replace(" ", "_", $string);
  echo $replace; // hello_php
?>
Comment

php replace all spaces with dashes

// Clean up multiple dashes or whitespaces
$string = preg_replace("/[s-]+/", " ", $string);
// Convert whitespaces and underscore to dash
$string = preg_replace("/[s_]/", "-", $string);
Comment

PREVIOUS NEXT
Code Example
Php :: php file exist 
Php :: var_dump smarty 
Php :: generate random unique hex color code using php 
Php :: laravel Str::random 
Php :: laravel migration check if table has column 
Php :: php replace by <br 
Php :: laravel migrate only 1 file 
Php :: laravel return back with success 
Php :: eloquent get random 
Php :: remove word from string php 
Php :: php get file created date 
Php :: update php version using htaccess 
Php :: hex to bin php 
Php :: mac php ini file path 
Php :: create model in laravel command line 
Php :: a2dismod php 8.0 
Php :: php loop 
Php :: Delete Query with Where Condition in Codeigniter 
Php :: laravel 8 db like query 
Php :: prepend 0 to number php 
Php :: php select version ubuntu 
Php :: php document root 
Php :: php get referral 
Php :: clear log file laravel command 
Php :: function exists php 
Php :: php get ip to location 
Php :: get custom field 
Php :: print array php 
Php :: api headers php 
Php :: laravel validation min string length 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =