我在while循环中有一个计数器,我想在数组中添加该计数的每个值?可能吗? 我尝试了什么:
$title_count = 0;
if(have_posts()){
while(have_posts()){
$title_count++;
the_post();
$max_array = array();
$add_to_array = array_push($max_array, $title_count);
}
}
答案 0 :(得分:2)
$title_count = 0;
$counts_array = array();
if(have_posts()){
while(have_posts()){
$title_count++;
the_post();
$counts_array[] = $title_count;
}
}
答案 1 :(得分:0)
试用此代码:
$title_count = 0;
$counts_array = array();
if(have_posts()){
while(have_posts()){
the_post();
array_push($counts_array,$title_count);
$title_count++;
}
}