ruslanashaari
9/8/2017 - 12:17 AM

Convert a number to a string, the contents of which depend on the number's factors. #exercism

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);
}