A
A
akula222017-05-29 20:01:32
PHP
akula22, 2017-05-29 20:01:32

How to display data from an array according to a certain limit?

There is an array

$array = [
            [
                'g' => 1,
                'n' => 'A'
            ],
            [
                'g' => 1,
                'n' => 'B'
            ],
            [
                'g' => 1,
                'n' => 'C'
            ],
            [
                'g' => 1,
                'n' => 'D'
            ],

            [
                'g' => 2,
                'n' => 'AA'
            ],
            [
                'g' => 2,
                'n' => 'BB'
            ],
            [
                'g' => 2,
                'n' => 'CC'
            ],
            [
                'g' => 2,
                'n' => 'DD'
            ]
        ];

$limit = 2;
print two ($limit) first records where g=1 and two ($limit) records where g=2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-05-29
@sergiks

Sequentially sort out, and count how many scored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question