Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Wordpress Timber(Twigg)中创建一个简单的计数循环?_Php_Wordpress_Twig - Fatal编程技术网

Php 如何在Wordpress Timber(Twigg)中创建一个简单的计数循环?

Php 如何在Wordpress Timber(Twigg)中创建一个简单的计数循环?,php,wordpress,twig,Php,Wordpress,Twig,如何在Wordpress Timber(Twigg)中创建一个简单的计数循环 基本上就是这样一个循环: ($i = 0;0 < 3;i++){ echo $test[i]; } ($i=0;0

如何在Wordpress Timber(Twigg)中创建一个简单的计数循环

基本上就是这样一个循环:

($i = 0;0 < 3;i++){
echo $test[i];
}
($i=0;0<3;i++){
echo$test[i];
}
您可以使用

{% for value in test %}
  {{ value }}
{% endfor %}
这比你想象的要安全

{% for i in 0..2 %}
    {{ test[i] }}
{% endfor %}
因为在第二个版本中,您必须关心索引(设置?等等),而在第一个版本中,您不关心索引。 当然,如果你的最终目标是从数组中只打印三个元素,那么你应该考虑

你可以用

{% for value in test %}
  {{ value }}
{% endfor %}
这比你想象的要安全

{% for i in 0..2 %}
    {{ test[i] }}
{% endfor %}
因为在第二个版本中,您必须关心索引(设置?等等),而在第一个版本中,您不关心索引。 当然,如果你的最终目标是从数组中只打印三个元素,那么你应该考虑

你可以用

{% for value in test %}
  {{ value }}
{% endfor %}
这比你想象的要安全

{% for i in 0..2 %}
    {{ test[i] }}
{% endfor %}
因为在第二个版本中,您必须关心索引(设置?等等),而在第一个版本中,您不关心索引。 当然,如果你的最终目标是从数组中只打印三个元素,那么你应该考虑

你可以用

{% for value in test %}
  {{ value }}
{% endfor %}
这比你想象的要安全

{% for i in 0..2 %}
    {{ test[i] }}
{% endfor %}
因为在第二个版本中,您必须关心索引(设置?等等),而在第一个版本中,您不关心索引。 当然,如果你的最终目标是从数组中只打印三个元素,那么你应该考虑


谢谢你Don第二个正是我需要的!只需要3个:)谢谢你,唐第二个正是我需要的!只需要3个:)谢谢你,唐第二个正是我需要的!只需要3个:)谢谢你,唐第二个正是我需要的!只需要3个:)