Hello. Does anyone know if there is a built in function if I wanna do something like: I have int .12345678 and I want to just grab the fourth decimal so that it will just display 4. Thanks!
No need for a special function, that's just a regular expression:
<?php $x = 0.12345; preg_match ("/\.\d{3}(\d)/", $x, $m); echo $m[1]; ?>
Grrrrr. One of these days I'll remember to escape backslashes when posting code: :mad:
preg_match ("/.\d{3}(\d)/", $x, $m);
Why preg? Wouldn't substr do?
substr might work, depends on what he meant by "fourth digit"
0.12345 123.45 .12345 etc...