-2

Got this array returned from Google Analytics Reporting API.

Array ( [0] => Array ([0] => Downloads [1] => click [2] => Spring 2015 | 1001295 | NO CODE [3] => 1 [4] => 1),
        [1] => Array ([0] => Downloads [1] => click [2] => Spring 2015 | 1001816 |         [3] => 1 [4] => 1), 
        [2] => Array ([0] => Downloads [1] => click [2] => Spring 2015 | 1002500 |         [3] => 1 [4] => 1),
        [3] => Array ([0] => Downloads [1] => click [2] => Winter 2015 | 1004130 |         [3] => 1 [4] => 1),
        [4] => Array ([0] => Downloads [1] => click [2] => Winter 2015 | 1005166 |         [3] => 1 [4] => 1),
        [5] => Array ([0] => Downloads [1] => click [2] => Winter 2015 | 1009161 |         [3] => 1 [4] => 1),
        [6] => Array ([0] => Downloads [1] => click [2] => Winter 2015 | 1009480 |         [3] => 1 [4] => 1),
        [7] => Array ([0] => Downloads [1] => click [2] => Winter 2015 | 1009819 | NO CODE [3] => 1 [4] => 1),
        [8] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1009828 |           [3] => 1 [4] => 1),
        [9] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1012443 | NO CODE   [3] => 1 [4] => 1),
       [10] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1013870 | NO CODE   [3] => 1 [4] => 1),
       [11] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1014200 |           [3] => 1 [4] => 1),
       [12] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1014378 |           [3] => 1 [4] => 1),
       [13] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1014408 |           [3] => 1 [4] => 1),
       [14] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1014452 |           [3] => 1 [4] => 1),
       [15] => Array ([0] => Downloads [1] => click [2] => Fall 2014 | 1015367 |           [3] => 1 [4] => 1),
       [16] => Array ([0] => Downloads [1] => click [2] => Summer 2014 | 1015959 |         [3] => 1 [4] => 1),
       [17] => Array ([0] => Downloads [1] => click [2] => Summer 2014 | 1016689 |         [3] => 1 [4] => 1),
       [18] => Array ([0] => Downloads [1] => click [2] => Summer 2014 | 1017426 | NO CODE [3] => 1 [4] => 1),
       [19] => Array ([0] => Downloads [1] => click [2] => Summer 2014 | 1021750 |         [3] => 1 [4] => 1),
       [20] => Array ([0] => Downloads [1] => click [2] => Summer 2014 | 1022956 |         [3] => 1 [4] => 1),
       [21] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1026419           [3] => 1 [4] => 1),
       [22] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1026813           [3] => 1 [4] => 1),
       [23] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1028789           [3] => 1 [4] => 1),
       [24] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1029245           [3] => 1 [4] => 1),
       [25] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1032008           [3] => 1 [4] => 1),
       [26] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1033724           [3] => 1 [4] => 1),
       [27] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1034546           [3] => 1 [4] => 1),
       [28] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1035929           [3] => 1 [4] => 1),
       [29] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1036488           [3] => 1 [4] => 1),
       [30] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1038064           [3] => 1 [4] => 1),
       [31] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1043900           [3] => 1 [4] => 1),
       [32] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1044241           [3] => 1 [4] => 1),
       [33] => Array ([0] => Downloads [1] => click [2] => spring_2015 | 1045560           [3] => 1 [4] => 1),
       [34] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1045928           [3] => 1 [4] => 1),
       [35] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1046329           [3] => 1 [4] => 1),
       [36] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1046504           [3] => 1 [4] => 1),
       [37] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1048908           [3] => 1 [4] => 1),
       [38] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1051460           [3] => 1 [4] => 1),
       [39] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1051466           [3] => 1 [4] => 1),
       [40] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1052350           [3] => 1 [4] => 1),
       [41] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1054942           [3] => 1 [4] => 1),
       [42] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1056467           [3] => 1 [4] => 1),
       [43] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1057099           [3] => 1 [4] => 1),
       [44] => Array ([0] => Downloads [1] => click [2] => winter_2015 | 1057666           [3] => 1 [4] => 1)
)

I need to remove the first 2 members of each array item. How would I do that?

3
  • So you want to remove [0] => Downloads and [1] => Click from each of them? Commented Jul 16, 2015 at 18:10
  • possible duplicate of PHP - remove element in multidimensional array Commented Jul 16, 2015 at 18:10
  • @Glorfindel, there's no reason to request a close here, it is different than the one you mentioned. Besides, i have already selected the answer by Rizier123 Commented Jul 16, 2015 at 18:47

1 Answer 1

1

This should work for you:

Just loop through each element of your array with array_map() and just return an array_slice() with the offset of 2.

$newArray = array_map(function($v){
    return array_slice($v, 2);
}, $oldArray);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.