<?php
$string = 'this-is_a-test';

function toUpper($matches) {
  return strtoupper($matches[1]);
}

echo preg_replace_callback('/[-_](.)/', 'toUpper', $string);  
?>