php - 树枝中的多个字符串值包含检查?
问题描述
我想检查变量中是否包含多个字符串值,到目前为止,我知道我可以检查变量中是否包含单个字符串值,但在多个值包含中没有找到任何内容。
谁能帮我吗?
我现在拥有的:
{% if "VenuesController::detailsAction" not in controllerAndActionName %}
我想做的事:
{% if ["VenuesController::detailsAction", "VmsController::indexAction", "DefaultController::headerAction"] not in controllerAndActionName %}
这可能吗?
解决方案
不知道您是否可以直接在 中执行此操作twig
,但解决方法应该是这样
{% set bool = true %}
{% for string in ["VenuesController::detailsAction", "VmsController::indexAction", "DefaultController::headerAction"] %}
{% if string in controllerAndActionName %}
{% set bool = false %}
{% endif %}
{% endfor %}
{% if bool %}
Foo
{% endif %}
推荐阅读
- python - 如何使用 Python 在 Outlook 中提取电子邮件正文的一小部分?
- docker - 有没有办法找出用于构建映像的 docker 版本?
- android - 阅读收件箱中的所有短信或将其发送到 React NATIVE 中的服务器
- python - pysftp 身份验证超时
- flutter - 如何使用 BuildContext 判断页面是否已被释放
- sql - PostgreSQL 中的无方向关系失败
- java - 使用嵌入式 H2 的 Spring Boot 测试执行 10 倍于 init 脚本
- sql - 使用 SQL 查询从新列中的表中提取值
- python - 将 curl 转换为 python 请求,包括 cookie
- python - 如何在给定条件下选择两个数组的元素?