New on LowEndTalk? Please Register and read our Community Rules.
PHP question

in Help
HI all,
Just a quick one, what's the best way to remove the part before a decimal place and the part after a decimal place in a string.
E.g
string of "12345.567843
I need to return both 12345 and 567843 seperately
Thanks in advance.
Comments
use the explode function
Outputs:
Perfect, thanks!
GOD BLESS OVERKILLING
But regex's are so slow
In reality I'd probably do:
After first testing that $value is in the expected format.
I feel like we should have a competition to see who can do this using the most code.
What did I start...
It's interesting to see how many different ways a simple task can be accomplished
I can take a nap while that preg_match is running ;-)
What no sed or awk? This thread would not be complete without it.
lol you guys seems bored...
This only removes the decimal. Too lazy to figure out the rest.
echo '12345.567843' | sed 's/.//g'
That removes everything.
I guess that you mean
echo '12345.567843' | sed 's/\.//g'
Yeah, silly forum engine.
pretty bored.
Thanks for catching that. Yea, posted without the {code} tags at first and it must have stripped that.
print substr($word, 0, strpos($word,".")). " ". substr($word, strpos($word,".")+1);