If at all possible, I would call one function from the inside.
function getSingle($arg) { // Do whatever it is your function should do... return 1; } function getMultiple($args) { $out = array(); foreach ($args as $arg) { $out[] = getSingle($arg); } return $out; }
It may not be possible for the function you mean, but it may be a good option.
As an additional note, since functions are related to each other, I will write them as class methods to “group” them together.
Take Users , for example; I may need a function to get one user and another for multiple users. It makes sense to collect these methods in a class:
class Users { public function getUser($id){} public function getUsers(array $id = null){} }
adlawson
source share