<?php

function sendResponse($data, $code = 200) {
    http_response_code($code);
    echo json_encode($data);
    exit;
}

function sendSuccess($data = [], $message = '') {
    $response = ['status' => true];
    if ($message) $response['message'] = $message;
    if (!empty($data)) $response = array_merge($response, $data);
    sendResponse($response);
}

function sendError($message, $code = 400) {
    sendResponse(['status' => false, 'message' => $message], $code);
}
