php preg_replace , I need to replace everything after a dot (e.g 340.38888 > need to get clean 340)

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-16T12:48:36Z Indexed on 2010/05/16 12:50 UTC
Read the original article Hit count: 265

Filed under:
|

I need to replace everything after a dot . I know that it can be done with regex but I'm still novice and I don't understand the proper syntax so please help me with this .

I tried the bellow code but doesn't work :

  $x = "340.888888";
$pattern = "/*./"
 $y = preg_replace($pattern, "", $x);
print_r($x);

thanks , Michael

© Stack Overflow or respective owner

Related posts about php

Related posts about preg-replace