I want to archieve the following:
"I am a descriptive sentence"
I put it in an array (for creating keywords for meta tags) via:
[{assign var='meta_key_arr' value=' '|explode:$oEntry->FCLONGDESC_1}]
That works so far. My result is an array like that:
array([I],[am],[a],[descriptive],[sentence])
The goal is to get a String like that "I,am,a,descriptive,sentence"
I wanted to implode the array seperated by a comma: [{', '|implode:$meta_key_arr}]
This works fine, but I want to assign the values to another variable $meta_key. Which does not work. I read the manual but the only thing I could find was the syntax above.
[{assign var='meta_key' value=' '|', '|implode:$meta_key_arr}]
did not work. And this didn't work either.
[{assign var='meta_key' value=' ' ', '|implode:$meta_key_arr}]
How can I use the implode function correct? There is a much easier way for sure.
The solution:
[{foreach from=$meta_key_arr item=mkey}]
[{assign var='meta_key' value=', '|implode:$meta_key_arr}]
[{/foreach}]
您为什么不只使用原始字符串并用逗号替换空格?
[{assign var='meta_key' value=$oEntry->FCLONGDESC_1|replace:' ':', '}]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.