**Foto casuale**
This is a random image
DEMO OF THE WORKAROUD SOLUTION
categories->category as $value) { $count_images += $value->attributes()->total_nb_images; } echo 'Calculated total images: ' . $count_images . ' => Calculated number of pages: ' . intval($count_images/$per_page) . '
'; //start parsing the web api output with the workaround logic $per_page1 = $per_page * 2; //we need to retrive double number of specified pages because $count_images/$per_page is float number. we will slice it at the end $pages1 = intval($count_images/$per_page1); // $webapi3 = "http://gallery.carrimerci.it/ws.php?format=rest&method=pwg.categories.getImages&order=date_available&per_page=" . $per_page1 . "&page=" . $pages1; echo 'The calculated Web Api request is: ' . $webapi3 . '
'; $strXml3 = file_get_contents($webapi3); $objXml3 = new SimpleXmlElement($strXml3); $piwigo2 = array(); $counter2 = 1; foreach($objXml3->images->image as $value) { $thumbs_string = strval($value->derivatives->square->url); $url_string = strval($value->categories->category->attributes()->page_url); $piwigo2[$counter2]['thumb'] = $thumbs_string; $piwigo2[$counter2]['url'] = $url_string; $counter2++; } $piwigo2 = array_reverse($piwigo2); $piwigo2 = array_slice($piwigo2, 0, $per_page); foreach($piwigo2 as $value) { echo ' ' . '' . PHP_EOL; }