- array_slice: documentation ( source)
- array_merge: documentation ( source)
- array_filter: documentation ( source)
- join: documentation ( source)
- sprintf: documentation ( source)
<?php
$algorithms = array('ssh-rsa', 'ssh-dss', 'ssh-ed25519');
$algorithm_string = join(' or ', array_filter(array_merge(array(join(', ', array_slice($algorithms, 0, -1))), array_slice($algorithms, -1)), 'strlen'));
echo sprintf('The key is invalid. It must begin with %s.', $algorithm_string);