Norsk.Firefox Posted April 5, 2008 Share Posted April 5, 2008 Hello, I use this preg_replace: preg_replace('/\{(.*?).*?)\}/e', 'replace(${1}, ${2})', $var); witch calls this function: function replace($array, $var) { switch($array) { case 'GET': return $_GET[$var]; case 'POST': return $_POST[$var]; case 'DATA': return data[$var]; } return ''; } This part works fine with {DATA:abc}, {GET:page} etc. But I do also want to the possible to choose between elements, so when i trie to add another case to the switch and use {TIF:DATA,abc,0=zero,1=one} it won't work any more. I get this error: Parse error: syntax error, unexpected '=' in C:\page.php(101) : regexp code on line 1 Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: replace(TIF:DATA,abc,0=zero,1=one) in C:\page.php on line 101 Anyone have a solution to this problem? Link to comment https://forums.phpfreaks.com/topic/99761-problems-with-preg_replace/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.