Programmatically convert single classic block to individual blocks via PHP

I ended up writing a function that wraps the <p> tags in the block comments. This forced the content to be individual paragraph blocks in the editor. My content was only paragraphs but other block types would need to be implemented as well.

function blockify_content($content) {
    //remove empty <p>
    $pattern = "/<p[^>]*><\\/p[^>]*>/";
    $content = preg_replace($pattern, '', $content);

    //add block comments
    $search = array('<p', '</p>');
    $replace = array('<!-- wp:paragraph --><p', '</p><!-- /wp:paragraph -->');
    $content = str_replace($search, $replace, $content);
    return $content;
}

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedueduseduedueduedueduseduedus