paginate through photos to grab all

While grabbing a users photos, paginate through the next url's to grab all their photos.

while(isset($nextURL))
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $nextURL);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$instagramString = curl_exec($ch);
	curl_close($ch);

	$instagram = json_decode($instagramString, true); 

	$data = $instagram['data'];
	$pagination = $instagram['pagination'];
	$nextURL = $pagination['next_url'];

	for($i=0;$i\"instagram\"
"; } }