RE: [PHP] preg_replace wierdness

2002-11-22 Thread John W. Holmes
> Code snippet -> > > header('Content-type: text/plain'); > > $foo = ' '; > > echo "$foo\n"; > > > $path = '../../../'; > $bar = preg_replace('/()/', "$1" . $path . "$2", $foo); > > echo $bar; It's being greedy. Your pattern is matching ( ) and inserting $path between the two. Use $bar

[PHP] preg_replace wierdness

2002-11-22 Thread Gerard Samuel
Code snippet -> header('Content-type: text/plain'); $foo = ' '; echo "$foo\n"; $path = '../../../'; $bar = preg_replace('/()/', "$1" . $path . "$2", $foo); echo $bar; ?> The second image doesn't get affected by preg_replace(). But if I break $foo into multiple lines like -> $foo = '