In PHP we have so many functions which are related to strings. The below examples explains how to remove the spaces between string.
1. str_replace
2. preg_replace.
str_replace:
This replaces the empty spaces. this can be used partially.
Example:
$string = str_replace(' ', '', $string);
preg_replace:
This will replace the nth spaces and removes the white spaces within all the string.
Example:
$string = preg_replace('/\s+/', '', $string);
Monday, February 3, 2014
Remove spaces between two string
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment