dro60731 2014-04-15 13:51
浏览 416

PHP - 如何在while循环中将数组组合成一个数组?

I have this code which gives me post_permalink in a while loop.

<?php 
  $value[] = array();
    while ($the_query->have_posts()) : $the_query->the_post()
                $value[] =array(
                    'post_permalink' => get_permalink()
                );

 endwhile; ?>

Now the thing is that I'm getting the links as

    Array ( [0] => Array ( [post_permalink] => link ) 
            [1] => Array ( [post_permalink] => link ) 
            [2] => Array ( [post_permalink] => link ) 
            [3] => Array ( [post_permalink] => link ) )

The way I want it to be:

        Array ( [post_permalink] => link  
                [post_permalink] => link 
                [post_permalink] => link 
                [post_permalink] => link  )

i.e: All of the links in one array instead of four subarrays. Please help!

  • 写回答

3条回答 默认 最新

  • drny60365 2014-04-15 13:54
    关注
    foreach($value[0] as $k=>$v)
       $result[$k]=$v
    
    评论

报告相同问题?

悬赏问题

  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)