I want to replace a chosen username with blankspaces with no spaces.
preg_replace("[ ]", "", $username);
I want to replace a chosen username with blankspaces with no spaces.
preg_replace("[ ]", "", $username);
You can follow any of the methods provided below for the removal of the white spaces from the string.
str_replace
: str_replace()$chosen_string = str_replace(' ', '', $chosen_string);
preg_replace
: preg_replace()$chosen_string = preg_replace('/\s+/', '', $chosen_string);
Cheat Sheet Reference: