In the function below, you need to update two lines if you don't want php to throw warnings.
change these two:
$elements[$index]['attributes'] = $tag['attributes'];
$elements[$index]['content'] = $tag['value'];
to this:
$elements[$index]['attributes'] = empty($tag['attributes']) ? "" : $tag['attributes'];
$elements[$index]['content'] = empty($tag['value']) ? "" : $tag['value'];