0

I wonder is there a good way to refactor this simple problem, without using round each line, or a foreach... :

<?php
$x =1,999999;
$y = 3.1562;
$z = 4.433232;

$x = round($x);
$y = round($y);
$z = round($z);


?>

Edit : Of course, without using immediatly $x = round(1.9999). (it's just used for the example).

4
  • I dont understand for what you can use it that. Can you write an example?
    – MR Mark II
    Sep 17, 2021 at 12:31
  • this question is more appropriate for codereview.stackexchange.com Sep 17, 2021 at 12:33
  • 1
    Yes. $x=2; $y=3; $z=4; simple refactoring
    – RiggsFolly
    Sep 17, 2021 at 12:56
  • Smart Riggs. But not useful.
    – Zabz
    Sep 17, 2021 at 13:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.