Skip to content

Instantly share code, notes, and snippets.

@fmkoc
fmkoc / floatceil.php
Created April 7, 2024 19:31
PHP floatceil Function: This Gist provides a floatceil function implemented in PHP, designed to ceiling floating point numbers to a specific decimal precision. Unlike the standard ceil() function which only works on the whole number, floatceil allows for adjusting the precision of the ceiling operation, making it extremely useful for financial c…
<?php
function floatceil($number, $precision=2) {
$significance = 1/pow(10,$precision);
return number_format(ceil($number/$significance)*$significance, $precision, '.', '');
}
/*
Examples:
floatceil(1, 2) -> 1.00
floatceil(1.035, 2) -> 1.04
@fmkoc
fmkoc / telegram.php
Last active June 22, 2025 18:15
Login with Telegram | PHP Guide
<?php
define('TELEGRAM_BOT', 'YOUR_BOT'); // Username of the bot (Generated on @BotFather)
define('TELEGRAM_TOKEN', 'YOUR:TOKEN'); // Token of the bot (Generated by @BotFather)
//Data validation function
function checkTelegramAuthorization($auth_data) {
$check_hash = $auth_data['hash'];
unset($auth_data['hash']);
$data_check_arr = [];
foreach ($auth_data as $key => $value) {