0

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
?>
2
Contributors
1
Reply
8
Views
1 Year
Discussion Span
Last Post by rubberman
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.