$link = 'mysite.com/es/home.html'
$link = ereg_replace('/es/','/en/', $link);
return $link;This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.You could try :
$link = 'mysite.com/es/home.html'
$link = preg_replace('/es/','en', $link);
return $link;