dongxian8858
2015-11-29 19:26
浏览 242
已采纳

如何只保留数组的第一个数组?

The title is a bit 'misleading, but the question is simple and I will try to explain what I'm trying to do. Typically to remove the indexes of an array I using unset, but in this case I have an array containing other arrays, each array is classified with an index. What I want to do is to keep only the first array and eliminate unset with everyone else, how?

Example structure

array(7) { 
           [0]=> array(14) { ... } 
           [1]=> array(14) { ... }
          }

I want keep only the array with 0 index, so the first array available. How do this?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanmo7075 2015-11-29 19:32
    已采纳

    reset sets the pointer to the first item in an array and returns it:

    $item = reset($array);
    

    $item will contain the array found in the first index.

    点赞 打赏 评论

相关推荐 更多相似问题