Yes. [man]substr[/man]
<?php
$num = 118.74999669307;
$cut = substr($num, 0, ((strpos($num, '.')+1)+2));
// Cut the string from first character to a length of 2 past the decimal.
// substr(cut what, start, ( (find position of decimal)+decimal itself)+spaces after decimal) )
echo $cut;
?>
Works.
You can even make this into a function like so:
function sigdig($num, $sep='.', $sig=2, $ret=FALSE)
{
$cut = substr($num, 0, ( (strpos($num, $sep)+1)+$sig ));
if($ret){ return $cut; }
else{ echo $cut; }
}
$num = array(118.74999669307, 18501.183501, 65184.16510083, 514.6611);
foreach($num as $n)
{
sigdig($n, '.');
echo '<br>';
}
That outputs:
118.74
18501.18
65184.16
514.66
~Brett