strlen($p) > 0); $absolutes = []; foreach ($parts as $part) { if ($part == '.') { continue; } if ($part == '..') { array_pop($absolutes); } else { $absolutes[] = $part; } } return implode('/', $absolutes); } } if (!function_exists('get_ip_from_hostname')) { function get_ip_from_hostname(string $hostname): string|bool { $validARecords = @dns_get_record($hostname, DNS_A); if ($validARecords) { return collect($validARecords)->first()['ip']; } $validAAAARecords = @dns_get_record($hostname, DNS_AAAA); if ($validAAAARecords) { return collect($validAAAARecords)->first()['ipv6']; } return false; } } if (!function_exists('format_number')) { function format_number(int|float $number, ?int $precision = null, ?int $maxPrecision = null): false|string { try { return Number::format($number, $precision, $maxPrecision, auth()->user()->language ?? 'en'); } catch (Throwable) { // User language is invalid, so default to english return Number::format($number, $precision, $maxPrecision, 'en'); } } }