I tried to make a custom php shortcode coverter for my own cms but the shortcodes are not converting in a proper way in the output its not displaying anything though as in replacement of corusel it should display Rollercoaster but right now I am getting output as This is a test page use to check the property [shortcode name='corusel'] but it should display as
This is a test page use to check the property Rollercoaster can anyone help me out with this concern please

<?php 
    // both content are same
    //<p>&nbsp;This is a test page use to check the property [shortcode name=&#39;corusel&#39;]</p>
    // In database table it stored in this format
    $page_content = $pages->row()->content; //When I run this it did not replaced 
    $content = "This is a test page use to check the property [shortcode name='corusel']"; //When I run this it replaced 
    $regex = '~\[.*?name=([\'"])([^\'"]+)\1\]~';

    $content = preg_replace_callback($regex, 
        function ($match) {
            $replacements = array('corusel' => 'Rollercoaster');//this is the value which is being replaced with [shortcode name='corusel']
            $match[2];
            $key = $match[2];
            return $replacements[$key];
        },
    $content
    );
    echo $content
?>

So, given a specific input, show the output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.