php replace space with dash

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

4
9
Phoenix Logan 186125 points

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

4 (9 Votes)
0
3.67
3
Phoenix Logan 186125 points

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

3.67 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
php string replace dash with space CAHNGE TEXT to small and add replace space with dash php php replace spaces with dashes in string php lower case and replace spacer for dash replace all spaces with dashes php how to change spaces to dash in php php replace all spaces with dashes with underscore php replace all spaces with dashes with space replace space with dash in php Replace spaces with dash php php replace dash with space replace spaces with dashes php replace space in url with dash php string replace space with dash php string regex remove spaces and dashes replace space or dash with plus php php replace space and dash with underscore php replace space or comma with dash laravel check if string has spaces or dashes php regex replace spaces with dasehs change space to dash php laravel replace character with dash remove underscore and desh and capital php str_replace space with dash php dash where space php remove space and hyphen from string php remove spaces and dashes how to trim spaces and add dash in php php replace whitespace with dash how we replace space with dash in php replace space with dash php php string replace spaces with dashes replace space to dash and replce symbol php string php replace space by dash php replace dashes with spaces php change space to dash PHP replace all space with hyphen replace space with hyphen in php repalce spaces with dash php php str_replace underscore and dash from string php str_replace under score and dash from string replace only first whitespace with hyphen php replace first whitespace with hyphen php php url single dash php replace spaces with dashes php replace all spaces with dashes php replace space with dash php replace spaces remove dashes and spaces php php replace spaces with dash
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source