Jump to content

strtolower not working inside preg_replace


ibinod

Recommended Posts

Can anyone help me pls i can't get this working

 

$str = '<p>The reality TV’s most hated man has some harsh words for Oscar-winning actress <a href="http://www.mysite.com/name/Angelina_Jolie">Angelina Jolie</a>';

echo preg_replace('/http:\/\/www.mysite.com\/name\/(.*?)\//i',strtolower('\\1'),$str);

 

how can i modify this so the strtolower will work and only the last part string will be lowercased like Angelina_Jolie to angelina_jolie

 

Thanx.

if i use strtolower before preg_replace everything inside $str will be lowercased and i don't want that i just want the url last word to be lowercased

 

and cud you please provde me a sampe code or something i tried various thing but it's not working

and cud you please provde me a sampe code or something i tried various thing but it's not working

 

It'll be like this:

 

echo preg_replace('/http:\/\/www.mysite.com\/name\/(.*?)\//ie',"strtolower('\\1')",$str);

 

The e modifier tells it that the thing in the second argument should be evaluated as PHP code.

and cud you please provde me a sampe code or something i tried various thing but it's not working

 

It'll be like this:

 

echo preg_replace('/http:\/\/www.mysite.com\/name\/(.*?)\//ie',"strtolower('\\1')",$str);

 

The e modifier tells it that the thing in the second argument should be evaluated as PHP code.

 

 

Hi, thanks a lot it works when i use the e modifier but it add extra \ at the end how can i remove this

 

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.