Jump to content

[SOLVED] preg_replace problem with SPACES


mzhou88

Recommended Posts

$string='#function#hell world test#';
$pattern='/#function#(\d+)#/i';
$replace='<a href="http://gmail.com">${1}</a>';
preg_replace($pattern, $replace, $string)

 

For some reason, PHP cannot recognize my pattern when $string has a space in the variable. If I put hell_world_test instead of hell world test, it will work, but how do i do it so that it accepts spaces as well?

 

Thank you for all your help.

Link to comment
https://forums.phpfreaks.com/topic/39831-solved-preg_replace-problem-with-spaces/
Share on other sites

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.