I think these two conditions can be written in a simpler way as follows:

if ($token[0] == '{') 
{
 $article_str = '{';
}
else if ($token[1] == '}') 
{
  ... lines 35-44
} 
else
{
  $article_str = .= substr($token, 0, -1);
}