Here's an example of what you might do with preg_replace(), however be careful data mining Google.
<?php
$urls = array("http://fonts.googleapis.com/css?family=Oswald:400,300",
"http://fonts.googleapis.com/css?family=Roboto+Slab");
$patterns = array(
//replace the path root
'!^http://fonts.googleapis.com/css\?!',
//capture the family and avoid and any following attributes in the URI.
'!(family=[^&:]+).*$!',
//delete the variable name
'!family=!',
//replace the plus sign
'!\+!');
$replacements = array(
"",
'$1',
'',
' ');
foreach($urls as $url){
$font = preg_replace($patterns,$replacements,$url);
echo $font;
}
?>