【发布时间】:2014-05-29 22:15:28
【问题描述】:
我有这段代码,它在一个while循环中给了我post_permalink。
<?php
$value[] = array();
while ($the_query->have_posts()) : $the_query->the_post()
$value[] =array(
'post_permalink' => get_permalink()
);
endwhile; ?>
现在问题是我得到了links
Array ( [0] => Array ( [post_permalink] => link )
[1] => Array ( [post_permalink] => link )
[2] => Array ( [post_permalink] => link )
[3] => Array ( [post_permalink] => link ) )
我想要的样子:
Array ( [post_permalink] => link
[post_permalink] => link
[post_permalink] => link
[post_permalink] => link )
即:一个数组中的所有链接,而不是四个子数组。请帮忙!
【问题讨论】:
-
你说你想要的结果有多次相同的索引。我不认为这实际上是你想要的。
-
你的数组必须有唯一的键。真的没有办法解决这个问题。
-
是的,如果可能的话,我希望每个值都有相同的索引
-
"如果可能的话" 不是。
-
在尝试一堆事情之前,您可能应该花更多时间弄清楚您想要完成的确切目标是什么,以及完成该目标的结果应该是什么。
标签: php arrays multidimensional-array while-loop