Generation

generate functionSat, 29 Jul 2023

una funcion que agrupe los precios mas bajos de un e-commerce

// PHP function price($price) { if ($price <= 10) { echo '$'; } elseif ($price > 10 && $price <= 100) { echo '$$'; } elseif ($price > 100 && $price <= 1000) { echo '$$$'; } else { echo '$$$$'; } } function price($price) { switch ($price) { case ($price <= 10): echo '$'; break; case ($price > 10 && $price <= 100): echo '$$'; break; case ($price > 100 && $price <= 1000): echo '$$$'; break; case ($price > 1000): echo '$$$$'; break; } }

Questions about programming?Chat with your personal AI assistant