prepare($sql); //Excute Query $stmt->execute(); //Get results $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); //------------------------------------------ //CHANGE ROWID INTO UUID //------------------------------------------ function updateRowID($row) { $row['rowID'] = encodeUuid($row['rowID']); return $row; } $updatedData = array_map('updateRowID', $messages); //------------------------------------------ //JSON_ENCODE //------------------------------------------ $messages = json_encode($updatedData, JSON_UNESCAPED_UNICODE); } //Send results echo $messages; ?>