- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove comma from a string in PHP?
To remove comma, you can replace. To replace, use str_replace() in PHP.
Let’s say the following is our input string with comma
$name="John,Smith";
We want the output after removing comma from the above string is
JohnSmith
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php $name="John,Smith"; $result = str_replace(',', '', $name); echo "The actual value is=",$name,"<br>"; echo "After removing the comma(,)=",$result,"<br>"; ?> </body> </html>
Output
This will produce the following output
The actual value is=John,Smith After removing the comma(,)=JohnSmith
Advertisements