0

How can to remove colon's and white space's in a string by php.

.e.g: The Godfather: Part II

  • please use, For white space - >$removed_string = preg_replace('/\s\s+/', ' ',$string_to_remove); – Gopala krishnan Jan 13 at 10:21
  • That works, Thanks a lot. – Brock_s34 Jan 13 at 11:27
1

Check This Code:

$demo_string =  "The Godfather: Part II";

$demo_string = str_replace(':', '', $demo_string);

$demo_string = str_replace(' ', '', $demo_string);

output : TheGodfatherPartII

| improve this answer | |
  • this works, but I want to use preg_replace function. Thanks for your answer. – Brock_s34 Jan 13 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.