For my code above, it was written recently enough that I can recall some of the thinking behind stylistic choices.
I was thinking of the list being dynamic. I wanted to illustrate that and decided an entire self-contained page would be the way to make that illustration work. (Nevertheless I still delegated to jQuery instead of writing my own animation code - how to animate lists in JavaScript wasn't the point.)
Being an entire page, I treated it as a "view"-type thing: minimal code that was little more than "here's a load of data prepared earlier - display it". There wasn't going to be a whole big templating thing because that would have distracted from the point the way hand-crafted JS animation would've.
And why printf()? The second use is
printf('<div class="func %s" style="display:none">%s</div>', $extn, $func);
There are other ways of writing that:
<?php
echo '<div class="func ' . $extn . '" style="display:none">' . $func . '</div>';
echo "<div class=\"func $extn\" style=\"display:none\">$func</div>";
echo "<div class='func $extn' style='display:none'>$func</div>";
?><div class="func <?=$extn?>" style="display:none"><?=$func?></div><?php
And so on, but all made for more fiddly punctuation. Except maybe for the third.
Having chosen printf() for the second loop, consistency meant using it for the first as well.