Echo arrays and non-arrays


I am using preg_replace and have a mixture of numbered $pattern and $replace elements and also a couple of arrays.

Here is a shortened version of the code:

$string = $_POST[“url”];
$string = file_get_contents($string);

$patterns[0] = ‘/\bwoman\b/i’;
$patterns[1] = ‘/\bman\b/i’;
$patterns[2] = ‘/\bintwoman\b/i’;
$patterns[3] = ‘/\bintman\b/i’;

$patterns = array ( ‘/\balex\b/i’, ‘/\bcatherine\b/i’);

$replacements[0] = ‘intwoman’;
$replacements[1] = ‘intman’;
$replacements[2] = ‘man’;
$replacements[3] = ‘woman’;

$replacements = array (‘Adam’, ‘Craig’);

echo preg_replace ($patterns, $replacements, $string);

The output seems to ignore the numbered elements and just echo the arrays.
I can’t figure out why, does anyone know?

Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service