Insted of eval you could of used variable varibles
http://php.net/language.variables.variable
you shouldnt preg_replace that , either use simplexml (like eljellybeanfishdog said) or use preg_match and use its matches variable to extract the results
http://php.net/preg_match