Rick Dangereux Rick Dangereux - 5 months ago 13x
PHP Question

PHP : str_replace in PHP with removing extra symbols in string

Currently I want to pass links to my RSS feed parser from my postgreSQL database.

So far I was able to convert to an array of a single string the string reads like:

{"(\"(http://www.delawareriverkeeper.org/rss.xml)\")","(\"(http://www.littoralsociety.org/index.php?format=feed&type=rss)\")","(\"(\"\"http://www.nj.gov/dep/newsrel/newsrel.rss \"\")\")"}

Only one string.

We want to remove the extra parantheses, quotes, backslashes and brackets so it reads like "http://www.delawareriverkeeper.org/rss.xml", "http://www.littoralsociety.org/index.php?format=feed&type=rss" and so on.

We then plan splitting that into another array to pass into our parser.

I think str_replace is what I am looking for but I am having trouble of actually figuring out what to use to remove the extra quotes.


this seems trivial. have you tried?


$raw = '{"(\"(http://www.delawareriverkeeper.org/rss.xml)\")","(\"(http://www.littoralsociety.org/index.php?format=feed&type=rss)\")","(\"(\"\"http://www.nj.gov/dep/newsrel/newsrel.rss \"\")\")"}';

$clean = str_replace('\"', '', $raw);
$clean = str_replace(')', '', $clean);
$clean = str_replace('(', '', $clean);
$clean = str_replace('}', '', $clean);
$clean = str_replace('{', '', $clean);
$clean = str_replace(' ', '', $clean);

echo $clean;