explode ile;
<?
$ref = "http://www.play4me.com/game/play.php?g=41455466448";
$a = explode("g=", $ref);
$ref = $a[1];
echo $ref;
?>