Page 1 of 1
PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 3:58 am
by JAB Creations
I have a string such as "JAB Creations", what function would I use to strip spaces so the output would be "JABCreations"? Trim looks like it's intended for whitespace removal only.
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 4:05 am
by pcoder
Code: Select all
Use: str_replace(' ','','Jab Creations')
This will give the solution.
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 4:13 am
by JAB Creations
Thanks pcoder, I just found the same suggestion searching online...
I'm basically doing this to construct a file name so I know who uploads what. That way I can give credit to Onion when he uploads free dancing girls for me!
Code: Select all
<?php
$username = 'JAB Creations';
$filename = strtolower(str_replace(' ', '', $text));
echo $filename;
?>
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 5:47 am
by onion2k
JAB Creations wrote:That way I can give credit to Onion when he uploads free dancing girls for me!

I can do that. What's the URL?
Bizarrely enough, just yesterday I came up with an interesting idea for a password protection system that involves dancing. A computer would run an application that takes video footage of you dancing in front of your webcam, and encodes it into a passphrase. Then, if anyone wants access they have to beat you in a dance off. It's quite brilliant. In fact, I think it's the future.
*busts some moves*
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 5:52 am
by JAB Creations
Ha that's awesome! I'm actually working on polishing up existing features (working on cleaning up file structure this morning) and have to add some other things (the ability to report things in example) before I release my first Beta! I'll be sending PM's to mods when it's ready in a week or two and posting code in the critique forum as well.
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 6:01 am
by pcoder
Yeah really, it's quite brilliant, I can see the future with groomed technology.
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 6:09 am
by onion2k
JAB Creations wrote:I'll be sending PM's to mods when it's ready in a week or two
Why?
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 6:43 am
by JAB Creations
First beta will be closed though the source will be posted in the critique forum. I trust you guys and my close friends not to actually start posting dancing girls (being serious now) and to help me with the critical input I'm looking for. I'll be looking for security holes and the like which is why I don't want to test it too heavily. The second beta will be open to everyone when I'm sure things are solid security wise.
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 6:59 am
by onion2k
JAB Creations wrote:I'll be looking for security holes and the like which is why I don't want to test it too heavily.
Rather than assuming the mods will help why not post a thread in Volunteer Work asking for people to help, and then send the address of the Beta to the ones who offer that you trust. It's flattering that you think we're the ones to send it to, but a few of the mods are pretty busy these days...
Re: PHP Strip spaces from string? NOT whitespace!
Posted: Thu Sep 04, 2008 7:10 am
by JAB Creations
Well the code will be posted in the critique forum for everyone to see. If it looks secure to other people then I might post a link at least here on the forums. If pming mods with a link to check things out would be burdensome then I think I'll stop short of doing that.