⊗ppPmBsFTI 41 of 447 menu

Converting a Fraction to an Integer in PHP

Using the int command on a fraction will result in only the integer part being extracted from the fraction:

<?php $test = (int) '1.2'; var_dump($test); // outputs 1 ?>

The command works similarly in the case when we don't have a string with a fraction, but just a fraction as a number:

<?php $test = (int) 1.2; var_dump($test); // outputs 1 ?>

Convert the following string to an integer:

<?php $test = '12.345'; ?>
byenru