Skip to content

Instantly share code, notes, and snippets.

@ruslanashaari
Created September 8, 2017 00:17
Show Gist options
  • Save ruslanashaari/563bc0131bd4ed2bde43e8177cfefd41 to your computer and use it in GitHub Desktop.
Save ruslanashaari/563bc0131bd4ed2bde43e8177cfefd41 to your computer and use it in GitHub Desktop.
Convert a number to a string, the contents of which depend on the number's factors. #exercism
<?php
function raindrops($drops) {
$output = '';
if ($drops%3 == 0) {
$output .= "Pling";
}
if ($drops%5 == 0) {
$output .= "Plang";
}
if ($drops%7 == 0) {
$output .= "Plong";
}
return (empty($output) ? "$drops" : $output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment