Is using sleep() in PHP a viable solution for controlling the timing of API calls within a loop?

When making API calls within a loop in PHP, using sleep() can be a viable solution to control the timing between each call. This can help prevent rate limiting issues or overwhelming the API server with too many requests at once. By adding a sleep() function with a specified delay before each API call in the loop, you can ensure a more controlled and efficient execution of your requests.

foreach($items as $item) {
    // Make API call here
    
    // Add a delay of 1 second between each API call
    sleep(1);
}