> 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
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 = '
2 matches
Mail list logo