str_replace(' ', '-', $string);
<?php
$string = "hello php";
$replace = str_replace(" ", "_", $string);
echo $replace; // hello_php
?>
// Clean up multiple dashes or whitespaces
$string = preg_replace("/[s-]+/", " ", $string);
// Convert whitespaces and underscore to dash
$string = preg_replace("/[s_]/", "-", $string);
Code Example |
---|
Php :: string contains string laravel |
Php :: laravel model string primary key |
Php :: how to count string characters in php |
Php :: pi() in php |
Php :: hide php extension in url |
Php :: enie letter validation laravel regex |
Php :: fix to 2 decimal places php |
Php :: row count in codeigniter |
Php :: wordpress change site address |
Php :: laravel hash::check |
Php :: wp get all post categories |
Php :: random color php |
Php :: php round down |
Php :: beaver builder shortcode post title |
Php :: create unique filename php |
Php :: php artisan serve not working |
Php :: write to file laravel |
Php :: install php 7.3 on amazon linux 2 |
Php :: laravel insert |
Php :: PHP extension simplexml |
Php :: old value in laravel |
Php :: last login date time in wordpress |
Php :: log laravel |
Php :: check if number is float in php |
Php :: php mysql create table |
Php :: laravel password verification |
Php :: laravel any error |
Php :: php exit foreach |
Php :: wp safe redirect |
Php :: get hours difference between two dates in php |