php replace spaces with dash

Solutions on MaxInterview for php replace spaces with dash by the best coders in the world

showing results for - "php replace spaces with dash"
Margaux
04 Mar 2016
1str_replace(' ', '-', $string);
Juan Manuel
21 Nov 2019
1<?php 
2  $string = "hello php";
3  $replace = str_replace(" ", "_", $string);
4  echo $replace; // hello_php
5?>
Angelo
10 Aug 2018
1// Clean up multiple dashes or whitespaces
2$string = preg_replace("/[\s-]+/", " ", $string);
3// Convert whitespaces and underscore to dash
4$string = preg_replace("/[\s_]/", "-", $string);
queries leading to this page
replace dash with space phphow to change spaces to dash in phpphp replace space by dashreplace only first whitespace with hyphen phpphp replace all space with hyphenhow to replace space iwth dash phpchange space to dash phplaravel check if string has spaces or dashesphp replace space and dash with underscorephp dash where spacephp remove space and hyphen from stringphp str replace underscore and dash from stringphp replace dashes with spacesreplace space with hyphen in phpstr replace space with dashphp lower case and replace spacer for dashreplace spaces with dashes phpreplace first whitespace with hyphen phpphp replace spacesreplace all spaces with dashes phpphp replace spaces with dashesphp string regex remove spaces and dashesremove dashes and spaces phpreplace space in url with dash phpphp replace all spaces with dashes with underscorephp str replace under score and dash from stringall space replace with dash in phpreplace space to dash and replce symbol php stringhow to trim spaces and add dash in phpstring replace space with dashphp string replace space with dashphp remove spaces and dashesphp replace spaces with dashes in stringreplace space with dash phplaravel replace character with dashreplace space with dash in phprepalce spaces with dash phpphp replace whitespace with dashreplace spaces with dash phpremove underscore and desh and capital phphow we replace space with dash in phpreplace space or dash with plus phpphp replace space with dashphp change space to dashphp replace spaces with dashphp replace space or comma with dashphp string replace dash with spacephp url single dashphp replace all spaces with dashescahnge text to small and add replace space with dash phpphp regex replace spaces with dasehsphp replace all spaces with dashes with spacephp string replace spaces with dashesphp replace dash with spacephp replace spaces with dash