\n";
foreach ( $listing as $header => $icons ) {
$contents .= sprintf( "\n## %s\n\n", $header );
$chunks = array_chunk( $icons, $per_row );
$contents .= '
' . "\n";
foreach ( $chunks as $chunk_icons ) {
foreach ( $chunk_icons as $icon ) {
$file = $icon;
[ $name, $ext ] = explode( '.', get_basename($icon), 2 );
$format = '
'
. '

'
. '
%2$s';
$contents .= sprintf( $format, $file, $name ) . "\n";
}
}
$contents .= "
\n";
}
file_put_contents( $output, $contents );