[英]PHP and Twig Set Variable Value
I am working with CI Framework and using Twiggy Template Engine for this. 我正在使用CI Framework并为此使用Twiggy模板引擎。 I am getting issue from last day and after do everything i couldn't found solution about how to override php array value using twig.
我从前一天开始遇到问题,做完所有事情后,我找不到有关如何使用细枝覆盖php数组值的解决方案。 Here is code and with this you can understand more..
这是代码,通过它您可以了解更多。
$data['get_sup_sp_id'] = 6;
$data['profile'] = $this->user_model->get_sp_Profile($data['get_sup_sp_id']);
Twig Code : 树枝代码:
{{ dump(data.profile) }}
Twig code just dump array values but i want to set according to id but not want to set static as i already. 树枝代码只是转储数组值,但我想根据id进行设置,但又不想像我一样设置static。
Is there any solution in twig or twig filters with that i can set $data['get_sup_sp_id]; 在树枝或树枝过滤器中有什么解决方法可以设置$ data ['get_sup_sp_id];
Thanks 谢谢
You can merge a hash (php associative array) into an existing hash like so: 您可以将哈希(php关联数组)合并到现有哈希中,如下所示:
{{ dump(data|merge({ 'get_sup_sp_id': 2 })) }}
See more on merging here: http://twig.sensiolabs.org/doc/filters/merge.html#merge 在此处查看有关合并的更多信息: http : //twig.sensiolabs.org/doc/filters/merge.html#merge
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.