

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert spaces to dash and lowercase with PHP
The return value of strtolower can be passed as the third argument to str_replace (where $string is present). The str_replace function is used to replace a set of characters/character with a different set of character/string.
Example
$str = 'hello have a good day everyone'; echo str_replace(' ', '-', strtolower($str));
Output
This will produce the following output −
hello-have-a-good-day-everyone
- Related Questions & Answers
- Convert text to lowercase with CSS
- Adding dash between spaces in field name in MySQL?
- Count spaces, uppercase and lowercase in a sentence using C
- Java program to convert a string to lowercase and uppercase.
- C++ program to convert kth character to lowercase
- Convert string to lowercase or uppercase in Arduino
- How to convert Python dictionary keys/values to lowercase?
- Converting strings to uppercase and lowercase with vanilla JavaScript
- How to convert color spaces in OpenCV using C++?
- How to convert lowercase letters in string to uppercase in Python?
- Is there a MySQL command to convert a string to lowercase?
- Golang Program to convert Uppercase to Lowercase characters, using binary operator.
- Write a C program to convert uppercase to lowercase letters without using string convert function
- Why does Array.map(Number) convert empty spaces to zeros? JavaScript
- How to convert all uppercase letters in string to lowercase in Python?
Advertisements