From official system requirements:
PHP 5.3.x and higher may produce errors or unexpected behavior
Thus, sadly, what you are seeing is pretty much "expected" unexpected behaviour. Drop back to PHP 5.2.x (x ≥ 5) or upgrade to Drupal 7 or 8 for a full fix.
If you want to only fix this one, consider what AyeshK wrote in comment:
$elements variable probably contains an array element that the key does not start with a hash sign and the value is scalar.
There is a lot of things about array operators. Comments under PHP documentation shows that many things are far from obvious. Also, it changed a bit from version to version. Have you tested if
$elements is an array in the first place? "Simply" add tests to make sure if operand is still valid, and provide a fallback if it isn't (recreate original behaviour) and you will be good to go.