I have a multi-dimensional array and what i want is in each second degree of array values limit should be set to 4 only. Like i have a array of type:
Array
(
[test2] => Array
(
[0] => Array
(
[application_id] => 405275016
)
[1] => Array
(
[application_id] => 405275016
)
[2] => Array
(
[application_id] => 303198288
)
[3] => Array
(
[application_id] => 303841592
)
)
[test3] => Array
(
[0] => Array
(
[application_id] => 289267216
)
[1] => Array
(
[application_id] => 303198216
)
[2] => Array
(
[application_id] => 405275016
)
[3] => Array
(
[application_id] => 303198288
)
[4] => Array
(
[application_id] => 303841592
)
[5] => Array
(
[application_id] => 311430400
)
[6] => Array
(
[application_id] => 318096216
)
[7] => Array
(
[application_id] => 320256352
)
)
)
and what i want that if the inner arrays value exceed 5 count it should not add any further values to it. i have to format this above array to something like:
Array
(
[test2] => Array
(
[0] => Array
(
[application_id] => 405275016
)
[1] => Array
(
[application_id] => 405275016
)
[2] => Array
(
[application_id] => 303198288
)
[3] => Array
(
[application_id] => 303841592
)
)
[test3] => Array
(
[0] => Array
(
[application_id] => 289267216
)
[1] => Array
(
[application_id] => 303198216
)
[2] => Array
(
[application_id] => 405275016
)
[3] => Array
(
[application_id] => 303198288
)
[4] => Array
(
[application_id] => 303841592
)
)
)
here in second array array last 3 arrays were truncated in order to take only 5 count as a value. I have tried many a methods but none achieved this.
Any idea on how can i achieve this will be highly appreciated ??