Php Replace Spaces With Dash

[Solved] Php Replace Spaces With Dash | Php - Code Explorer | yomemimo.com
Question : php replace spaces with dash

Answered by : josh

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

Source : | Last Update : Thu, 28 May 20

Question : php replace space with dash

Answered by : khaled-hayek

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

Source : | Last Update : Fri, 25 Jun 21

Question : php replace all spaces with dashes

Answered by : geeky-bravo

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

Source : | Last Update : Wed, 08 Jul 20

Answers related to php replace spaces with dash

Code Explorer Popular Question For Php