Hi everyone,

I am currently working on making all the urls on my php site user (and search engine) friendly.

I have got the mod_rewrite part that converts the user friendly urls back into the real ones working, all I need help with is the function that converts all the links in my pages.

The function I have now is below. In my site engine, I call this function on the main page content right before gzipping it and echoing it to the browser. I also call this function when I want to convert a url ( such as one in an email before sending it). It doesn't quite work right now, and I am hoing someone can help me!

Code:
function convert_urls($s) 
{
	$in = array(
	  '|/([a-zA-Z0-9_]+)\.php(#?[a-zA-Z0-9_\.]+)|'
	, '|/([a-zA-Z0-9_\.]+)/([a-zA-Z0-9_]+)\.php(#?[a-zA-Z0-9_\.]+)|'
	, '|/([a-zA-Z0-9_\.]+)/([a-zA-Z0-9_]+)\.php\?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)(#?[a-zA-Z0-9_\.]+)|'
	, '|/([a-zA-Z0-9_\.]+)/([a-zA-Z0-9_]+)\.php\?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)&?(?:amp;)?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]*)(#?[a-zA-Z0-9_\.]+)|'
	, '|/([a-zA-Z0-9_\.]+)/([a-zA-Z0-9_]+)\.php\?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)&?(?:amp;)?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)&?(?:amp;)?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)(#?[a-zA-Z0-9_\.]+)|'
	, '|/([a-zA-Z0-9_\.]+)/([a-zA-Z0-9_]+)\.php\?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)&?(?:amp;)?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)&?(?:amp;)?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]+)&?(?:amp;)?([a-zA-Z0-9_\.]+)=([a-zA-Z0-9_\.]*)(#?[a-zA-Z0-9_\.]+)|'
	, '|/([a-zA-Z0-9_\.]+)/([a-zA-Z0-9_]+)\.php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