Jump to content

very simple regex question for someone who just cant code


bertom

Recommended Posts

Hello,

I was hoping to find an answer here on this question:

 

I need to convert some urls dynamically with php:

http://www.domain.com/something-variable/12345/

into

http://www.domain.com/something-variable/12345/?xx=yy

 

the last two parts of the url are variable, and as you can see, the the url needs a variable string attached at the end. (always the same). I told you it was easy.

 

I found out that this could be done through a preg_replace command, and I tried, but i have no idea how to fix this.

I am not a developer you see.

 

Any help is appreciated.

 

Thanks,

Bert

 

 

The i makes the pattern case insensitive. The $1 and $2 represent capture groups one and two. Basically it will insert in their places the values captured in the pattern between the corresponding set of brackets. So $1 will be the first directory in the URI and $2 it's child directory.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.