Doodood Posted May 16, 2010 Share Posted May 16, 2010 Hi, I'm having troubles using POSIX regex ! I know how to construct well-formed expressions, but hum... i'd like to replace some content by the row[$1] of an array... My tries : $query = preg_replace('#{([0-9]+)}#isU', $arr[$1], $this->query); $query = preg_replace('#{([0-9]+)}#isU', $arr['$1'], $this->query); $query = preg_replace('#{([0-9]+)}#isU', $arr["$1"], $this->query); $query = preg_replace('#{([0-9]+)}#isU', "$arr[$1]", $this->query); $query = preg_replace('#{([0-9]+)}#isU', "$arr['$1']", $this->query); None of them worked... If you have any idea ! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/201940-replacing-by-an-indexed-array-row/ Share on other sites More sharing options...
cags Posted May 16, 2010 Share Posted May 16, 2010 The preg functions are PCRE not POSIX. You will probably need to use preg_replace_callback to achieve this. Quote Link to comment https://forums.phpfreaks.com/topic/201940-replacing-by-an-indexed-array-row/#findComment-1059076 Share on other sites More sharing options...
Doodood Posted May 16, 2010 Author Share Posted May 16, 2010 This worked fine for me, thanks alot ! Quote Link to comment https://forums.phpfreaks.com/topic/201940-replacing-by-an-indexed-array-row/#findComment-1059103 Share on other sites More sharing options...
newbtophp Posted May 17, 2010 Share Posted May 17, 2010 This worked fine for me, thanks alot ! or use the e modifier. Quote Link to comment https://forums.phpfreaks.com/topic/201940-replacing-by-an-indexed-array-row/#findComment-1059619 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.