Re: Removing spaces from a string
| From: | Brian Clark | Date: | Sat, 06 Jan 2001 21:26:21 +0000 |
| Subject: | Re: Removing spaces from a string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33056@lists.php.net to get a copy of this message | ||
(BC == "Brian Clark") brianj@fusionwerks.com writes:
BC> (RI == "Ray Iftikhar") iftikhar@pacbell.net writes:
RI>> How would I go about removing the space from a string? (ie. 3
RI>> doors down ->> 3doorsdown) Last I checked I dont think that there
RI>> was a specific function for it.
Oh, and a function:
<?php
function stripSpaces($artist)
{
$artist = trim($artist); /* \n and \r as well */
$artist = str_replace(' ','',$artist);
return $artist;
}
$artist = 'The Barenaked Ladies';
print stripSpaces($artist);
?>
But I hardly see the point in going through all that when you can just
type it out in str_replace(). :-)
BC> <?php print str_replace(' ','','3 doors down'); ?>
RI>> Thanx in advance,
RI>> Ray...
BC> -Brian
-Brian
--
Paralysis through analysis.