How to paginate a Json return in PHP

Asked

Viewed 64 times

-1

Hello, then, I have a request GET for an API, which returns a json, only that the records are limited to 100 per page, reaching 100 it returns a parameter "next" with the link to next page... the problem is, how do I take all the results and put in an array? I did, but it’s not working.... follow code... I appreciate the help...

inserir a descrição da imagem aqui

1 answer

0

You can use a Slice in the array:

 $array = array_slice($body2, 3); 

And limit it as you make the pagination:

$array = array_slice($body2, -3, 3, true);

  • But how would I know the next link to the next page? each page returns a different link to the next page.

  • you use a GET for that.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.