-2

In my case I am having the following array:

$array = [[01], [01,02], [01,02,03], [01,02,03,04], [01,02,03,04,05], [01,02,03,04,05,06]];

So from above array, I need only the last array which contains

[01,02,03,04,05,06]
Vaibhav Mule
  • 4,771
  • 3
  • 34
  • 52
Anup Dhal
  • 81
  • 11
  • Don’t you think the information **in what language** you want this might be slightly important …? Please read actual tag descriptions! `get` does not fit here at all. – CBroe Sep 20 '17 at 11:16
  • Actually this is in JS. – Anup Dhal Sep 20 '17 at 11:19
  • `last = arr[arr.length - 1];` or `last = arr.pop();` which will also remove the last from `arr`. – Alex K. Sep 20 '17 at 11:21
  • And how hard is it to type “javascript get last array item” or similar into google …? https://stackoverflow.com/questions/3216013/get-the-last-item-in-an-array – CBroe Sep 20 '17 at 11:22

1 Answers1

1

For you to get an idea of how it is done, I'm writing this answer using JS

var myArray = [[01], [01,02], [01,02,03], [01,02,03,04], [01,02,03,04,05], [01,02,03,04,05,06]]

var lastElement = myArray[myArray.length - 1]

console.log(lastElement)
hlfrmn
  • 3,435
  • 1
  • 25
  • 33
Vamshi Gudipati
  • 929
  • 1
  • 8
  • 21