How can a loop in PHP be structured to delete all keys with a specific prefix in Memcache?

To delete all keys with a specific prefix in Memcache using a loop in PHP, you can first retrieve all keys using the `getAllKeys()` method, then iterate through the keys to check for the desired prefix and delete them using the `delete()` method.

// Connect to Memcache
$memcache = new Memcache;
$memcache->connect('localhost', 11211);

// Get all keys
$keys = $memcache->getAllKeys();

// Specify the prefix to delete
$prefix = 'prefix_to_delete';

// Loop through keys and delete those with the specified prefix
foreach ($keys as $key) {
    if (strpos($key, $prefix) === 0) {
        $memcache->delete($key);
    }
}

// Close Memcache connection
$memcache->close();