Split all images over x amount of pages with $_GET I would like to receive some feedback on the code I am currently using to display x amount of images on my website per
$success = true;
$page = array_key_exists('page', $_GET) ? $_GET['page'] : 1;

$all_pictures = glob('crossles/*.jpg');

$total_images = 0;
foreach ($all_pictures as $img_total) {
    $total_images++;
}

$images_per_page = 30;

$max_pages = ceil($total_images / $images_per_page);

if ($page &lt;= -1) {
    $success = false;
}

if ($page &gt; $max_pages) {
    $success = false;
}
if ($success === false) {
    echo &quot;&lt;div class='container text-center'&gt;&lt;p class='text-danger fs-32 mt-100'&gt;No pictures to be displayed.&lt;/p&gt;&lt;/div&gt;&quot;;
}

I know that $_GET is not the safest way of doing this but since it is only to retrieve images I don't think it is that big of an issue.
It would be nice if I could get some feedback to implement it to my code if needed.
$total_images = 0;
foreach ($all_pictures as $img_total) {
    $total_images++;
}



This could be just 

$total_images = ($all_pictures === false) ? 0 : count($all_pictures);


or 

if ($all_pictures === false) {
    $total_images = 0;
    $success === false;
} else {
    $total_images = count($all_pictures);
}


The glob function returns an array, so you can just do the normal array operations on it.  You only have to check for an error.  I'm not quite sure what your original code would have done if there was an error.  You might want to check later so you can say something like "Oops, there was an error looking for images!" rather than "No images".  


if ($page &lt;= -1) {



This is a weird way to write this.  First, what would you do if page were set to -.5 here?  Second, what does a page value of 0 mean?  You are defaulting to 1, so it would seem that you are 1-indexed.  So why accept anything less than 1?  Consider 

if ($page &lt; 1) {


That eliminates all the invalid values below the range.  

For much the same reason, 


$page = array_key_exists('page', $_GET) ? $_GET['page'] : 1;



should probably be 

$page = array_key_exists('page', $_GET) ? intval($_GET['page']) : 1;


Get parameters can be user input, so you should sanitize them to what you expect.  


    echo "&lt;div class='container text-center'&gt;&lt;p class='text-danger fs-32 mt-100'&gt;No pictures to be displayed.&lt;/p&gt;&lt;/div&gt;";



This is an odd way to write a string in PHP.  Using double quotes indicates that there is a value to interpolate in it.  But you don't have one here.  This could just as well be 

    echo '&lt;div class="container text-center"&gt;&lt;p class="text-danger fs-32 mt-100"&gt;No pictures to be displayed.&lt;/p&gt;&lt;/div&gt;';


or 

?&gt;
    &lt;div class="container text-center"&gt;
      &lt;p class="text-danger fs-32 mt-100"&gt;No pictures to be displayed.&lt;/p&gt;
    &lt;/div&gt;
&lt;?php


Consider moving the whole thing into a function or even a class.  

class Page_Handler {

    private $image_count;

    private $success = true;

    private $all_pictures;

    private $max_page_number;

    private $page;

    private $images_per_page = 30;

    function __construct($path = 'crossles/*.jpg') {
        $this-&gt;all_pictures = glob($path);
        $this-&gt;success = $this-&gt;parse();
    }

    private function parse() {
        if ($this-&gt;all_pictures === false) {
            return false;
        }

        $this-&gt;image_count = count($this-&gt;all_pictures);
        $this-&gt;max_page_number = ceil($this-&gt;image_count / $this-&gt;images_per_page);

        $this-&gt;page = array_key_exists('page', $_GET) ? $_GET['page'] : 1;
        if ($this-&gt;page &lt; 1 || $this-&gt;page &gt; $this-&gt;max_page_number) {
            return false;
        }

        return true;
    }


There would also be getters and possibly other helper methods.  I'll leave those as an exercise for the reader (mostly because I'm lazy).  Note that you could differentiate between a failure to load the images and an invalid page.  Those are two separate problems and you may want to message them differently, as one is a server error and the other is user error.  Page number out of range is often a problem that the user can fix.  

I changed the names of some of the variables.  I generally use a system where plural names indicate collections and singular names indicate scalars.  You don't have to follow the same system, but it's the one I use when writing code.  

One of the differences here is that the parse code doesn't have to keep processing after an error.  At the first error, it returns failure.