Page 1 of 1

Need code to remove '#'

Posted: Sun Jan 06, 2008 4:55 pm
by QuickSnail
Is there a way to remove a #.

I'm making a php generator for myspace layouts. But the problem is.. My color wheel produces the #html color.
Well myspace funks up when you give a color like #FF0000, what i need is to just have FF0000. ( Not necessary that color. )


Is there a tag or code of some sort that i could have on the second page or first don't matter to remove the '#' apon hitting the submit.

Posted: Sun Jan 06, 2008 5:15 pm
by Inkyskin

Code: Select all

str_replace("#", "", "#ffffff");

Posted: Sun Jan 06, 2008 5:22 pm
by QuickSnail
Now will that only take the # out of ffffff or will it take it out for all colors.

EDIT:

And where do i pu it exactly. Anywhere? Sorry iI'm rather new..

Posted: Sun Jan 06, 2008 5:24 pm
by Inkyskin
I presume you would pass the value via posting it, in which case if the form field where the value is stored is called "color" for example, you could use this:

Code: Select all

$_POST['color'] = str_replace("#", "", $_POST['color']);
EDIT:

In your HTML, you then have this:

Code: Select all

<input type="text" name="color" value="<?= $_POST['color']; ?>" />

Posted: Sun Jan 06, 2008 5:49 pm
by QuickSnail
ahhh k. Lemme try it out. Thanks.

Posted: Sun Jan 06, 2008 9:27 pm
by RobertGonzalez
To make it easy you could apply the replace to the entire $_POST array.

Code: Select all

<?php
$_POST = str_replace('#', '', $_POST);
?>