$url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, ]); if (!empty($headers)) { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } // Execute $response = curl_exec($curl); $error = curl_error($curl); curl_close($curl); if ($error) { print_r($error); exit; log_message('error', 'cURL Error: ' . $error); return false; } return $as_json ? json_decode($response, true) : $response; } } if (!function_exists('json_encode_decode')) { function json_encode_decode($type, $data) { if ($type == 'encode'){ return json_encode( $data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE ) ; }else{ return json_decode( $data, true ) ; } return null; } } if(!function_exists('number_format_no_round')){ function number_format_no_round($number, $decimals = 2, $dec_point = '.', $thousands_sep = ',') { $factor = pow(10, $decimals); // Truncate instead of rounding $truncated = floor($number * $factor) / $factor; return number_format($truncated, $decimals, $dec_point, $thousands_sep); } }