What is the limitation of generating multiple images using imagegif in PHP?

When generating multiple images using imagegif in PHP, the limitation is that each call to imagegif overwrites the previous image. To solve this, you can use output buffering to capture the image data and save it to separate files.

<?php
// Start output buffering
ob_start();

// Generate and output the first image
$image1 = imagecreate(100, 100);
imagegif($image1);

// Save the output buffer to a file
file_put_contents('image1.gif', ob_get_clean());

// Generate and output the second image
$image2 = imagecreate(100, 100);
imagegif($image2);

// Save the output buffer to a file
file_put_contents('image2.gif', ob_get_clean());

// Repeat the process for additional images
?>