donglu5728 2015-11-04 10:41
浏览 52
已采纳

用于字符串的Smarty通配符选择器

Quick and simple, I have an app that works entirely on Smarty; basically I have {if} statement to determine what URI is user currently viewing so I can decide what to serve, it looks like:

    $GLOBALS.user_page_uri == '/private-messages/contacts/'

That opens all contacts, and when you click on some you open /private-messages/contacts/ID So I need some kind of wildcard that will go at the end of code above so it only looks for "/private-messages/contacts/" and ignores everything after, I tried "*" and "%" but to no avail.

  • 写回答

1条回答 默认 最新

  • dongpao1918 2015-11-04 12:10
    关注

    After few hours of knocking around (I'm not an PHP/smarty expert) I managed to find solution, instead of $string = 'something' I used preg_match()

    So I got it working by giving:

    preg_match("/\/private-messages\/contacts.*/s", $GLOBALS.user_page_uri);
    

    Hope someone finds this helpful, I know it saved me a lot.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料