Looping Functions

So, this is probably the best code I’ll write all day. But, it also begs a question about coding best practices. Say you have a function:

coolFunction();

And coolFunction() is designed to go do something and spit it out based on some value:

coolFunction( $awesomeString );

And let’s say that there are several values for $awesomeString, so you end up calling the function several times in a row:

coolFunction( 'apple' );
coolFunction( 'orange' );
coolFunction( 'dog' );

As far as “best practices” are concerned, which way would you rather do it?

function coolFunction( $theString ) {
    echo $theString;
}

$awesomeStrings = array( 'apple', 'orange', 'dog' );

foreach( $awesomeStrings as $awesomeString ) {
    coolFunction( $awesomeString );
}

OR

function coolFunction() {
    $awesomeStrings = array( 'apple', 'orange', 'dog' );

    foreach( $awesomeStrings as $awesomeString ) {
        echo $awesomeString;
    }
}

coolFunction();