【问题标题】:Parse data between %%解析 %% 之间的数据
【发布时间】:2022-01-24 13:15:27
【问题描述】:

你能告诉我 %% 之间的字符串是否可以被解析,而不是显示例如%offerroomlistBox% ,我可以渲染另一个视图来显示我需要的数据。

我从数据库中获取数据,他们的 var_dump 是这样的

我唯一使用的是“描述”

我用最简单的方法在ckeditor上显示数据

<textarea >
echo $this->templatesList[0]['description']
</textarea >

templatesList 是以这种方式从数据库中获取的列表

    $TemplatesModel = new TemplatesModel();
    $this->view->templatesList = $TemplatesModel->getAll(['where'=>["kind='offers_email'"]]);

【问题讨论】:

    标签: php parsing zend-framework


    【解决方案1】:

    试试这个

    echo str_replace('%','',$this->templatesList[0]['description']);
    

    要了解 str_replace,请访问这里https://www.php.net/manual/en/function.str-replace.php

    【讨论】:

    • 它很好,但它不会让我解析其他“% %”值,只有一个。是否可以解析整个数组并检查所有可能性?
    • 知道了,str_replace 适用于数组。
    猜你喜欢
    • 2020-11-26
    • 2020-05-09
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 2020-11-05
    • 2019-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多