Created
February 18, 2021 22:13
-
-
Save placecodex/b87df9a479d4d40479718f83b5f947d6 to your computer and use it in GitHub Desktop.
obtener porcentaje de ganancia o perdida entre dos cantidades
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function obtenerPorcentaje($cantidad, $total) { | |
$porcentaje = ((float)$cantidad * 100) / $total; // Regla de tres | |
$porcentaje = round($porcentaje, 0); // Quitar los decimales | |
return $porcentaje; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment