griga, может так:
<?php
ob_start();
if(!array_key_exists('category', $_GET)) die();
include('scripts/connect.php');
$category=$conn->real_escape_string($_GET['category']);
$query = "SELECT id, subcategory FROM expenses_cat WHERE category='".$category."' AND inmenu = 1";
$result = $conn->query($query);
$output = array();
while($row=$result->fetch_assoc()){
$output[$row['id']]=$row['subcategory'];
};
ob_end_clean();
echo json_encode($output);
exit;