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 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭