Home Loop while changing the name of a variable

# Loop while changing the name of a variable

user4393
1#
user4393 Published in September 20, 2018, 12:44 pm

Using FaceBook PHP SDK, when I want to get the next page of results I call something along the likes of $next =$fb->next($response). Now for the next page, I would have to call$next2 = $fb->next($next). I want to put this into a loop as obviously, I will never know beforehand how many times to execute this until I get through all the pages of results. When there are no more pages, the $fb->next() call will = null. Here is an example without a loop: $reactions = array();
$response =$response->getGraphEdge();

foreach ($response as$reaction) {
$reactions[] =$reaction['name'] . " - " . $reaction['type']; }$next = $fb->next($response);
foreach ($next as$reaction) {
$reactions[] =$reaction['name'] . " - " . $reaction['type']; }$next2 = $fb->next($next);
foreach ($next2 as$reaction) {
$reactions[] =$reaction['name'] . " - " . $reaction['type']; }$next3 = $fb->next($next2);
foreach ($next2 as$reaction) {
$reactions[] =$reaction['name'] . " - " . $reaction['type']; } print_r($reactions);