I am developing a PHP script that will optimize all images in a zip file. I have written a function to optimize a single image. How can I this function so that all the images will be optimized at the same time. I don't know whether its multitasking or multithreading.
The current way I'm doing it is optimizing one by one which is taking too much time. Is there any way we can run multiple functions at the same time?
<?php
$img1 = "1.jpg";
$img2 = "2.jpg";
$img3 = "3.jpg";
optimize($img1); // \
optimize($img2); // execute these functions in same time
optimize($img3); // /
function optimize($image)
{
// code for optimization
}
?>