Collapsable print_r() tree with PHP 7 (w/o preg_replace() and /e)

后端 未结 1 732
广开言路
广开言路 2021-01-22 16:52

In order to print_r a collapsable tree, I\'m currently using his code which uses preg_replace() and the /e modifier, which is depreciated

相关标签:
1条回答
  • 2021-01-22 17:23

    You need to concat the variable $id value, try this:

    function callbackFunction($matches) {
        $id = substr(md5(rand().$matches[0]), 0, 7);
        return "$matches[1]<a href=\"javascript:toggleDisplay('$id');\">$matches[2]</a><div id='$id' style=\"display: none;\">'";
    }
    
    0 讨论(0)
提交回复
热议问题