This is wrong and will lead you into an endless loop:
$this->_replace_amp($post, $new_post);
You do not need to send new_postas an argument, and you also want to reduce the problem for each recursion. Change your function like this:
function _replace_amp($post = array())
{
$new_post = array();
foreach($post as $key => $value)
{
if (is_array($value))
{
unset($post[$key]);
$new_post[$key] = $this->_replace_amp($value);
}
else
{
$new_post[$key] = str_replace(':amp;', '&', $value);
unset($post[$key]);
}
}
return $new_post;
}
source
share