$value) { if (is_array($value)) { $data[$key] = convert_empty_strings_to_null($value); } elseif (is_object($value)) { $data[$key] = convert_empty_strings_to_null($value); } elseif ($value === '') { $data[$key] = null; } } } elseif (is_object($data)) { foreach ($data as $key => $value) { if (is_array($value)) { $data->$key = convert_empty_strings_to_null($value); } elseif (is_object($value)) { $data->$key = convert_empty_strings_to_null($value); } elseif ($value === '') { $data->$key = null; } } } return $data; } } if (!function_exists('prepare_json_response')) { /** * Prepare data for JSON response by converting empty strings to null * This is a convenience wrapper around convert_empty_strings_to_null * * @param mixed $data The data to prepare for JSON response * @return mixed The processed data ready for JSON encoding */ function prepare_json_response($data) { return convert_empty_strings_to_null($data); } }