php replace all spaces with dashes

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

showing results for - "php replace all spaces with dashes"
Pia
23 Jan 2020
1str_replace(' ', '-', $string);
Claris
19 Apr 2016
1<?php 
2  $string = "hello php";
3  $replace = str_replace(" ", "_", $string);
4  echo $replace; // hello_php
5?>
Vincent
30 Nov 2020
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
php remove space and hyphen from stringphp string replace dash with spacehow to change spaces to dash in phphow to replace space iwth dash phpreplace dash with space phpphp lower case and replace spacer for dashphp string regex remove spaces and dashesphp regex replace spaces with dasehsphp replace all spaces with dashesphp replace dashes with spacesphp replace all spaces with dashes with underscorereplace only first whitespace with hyphen phpreplace all spaces with dashes phpphp str replace underscore and dash from stringreplace spaces with dashes phphow we replace space with dash in phpphp string replace spaces with dashesphp replace space with dashremove underscore and desh and capital phpreplace space or dash with plus phpreplace space with dash phpreplace space with dash in phpphp replace space by dashphp replace whitespace with dashreplace space to dash and replce symbol php stringphp remove spaces and dashesremove dashes and spaces phpreplace space in url with dash phpreplace spaces with dash phpphp str replace under score and dash from stringphp replace space with dashrepalce spaces with dash phpphp replace spaces with dashcahnge text to small and add replace space with dash phpphp replace space and dash with underscorephp dash where spacephp replace all spaces with dashes with spacephp replace dash with spacephp replace spaces with dashes in stringphp change space to dashhow to trim spaces and add dash in phpstring replace space with dashstr replace space with dashreplace first whitespace with hyphen phplaravel replace character with dashchange space to dash phpphp replace all space with hyphenreplace space with hyphen in phplaravel check if string has spaces or dashesphp replace spacesphp replace spaces with dashesphp string replace space with dashall space replace with dash in phpphp replace space or comma with dashphp url single dashphp replace all spaces with dashes