Replace character in block of text
Posted: Mon Aug 07, 2006 3:37 am
I'm trying to replace all the " in a block of text with '. I'm using this code:
I get this error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home3/perks/public_html/replace.php on line 11
Any help is much appreciated
Code: Select all
<?php
$code=$_POST["code"];
if ($code != "")
{
$before = array("/"/");
$after = array("'");
$replace = str_replace($before, $after, $code);
echo "<textarea cols='40' rows='10'>$replace></textarea>";
}
else
{
echo "<form action='replace.php' method='post'>";
echo "Code: <br><textarea cols='40' rows='10' name='code'></textarea><br>";
echo "<input type='submit' value='Submit'>";
echo "</form>";
}
?>Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home3/perks/public_html/replace.php on line 11
Any help is much appreciated