Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JamesHusband/03ab5ad64209efbe34135efc65e21b6a to your computer and use it in GitHub Desktop.
Save JamesHusband/03ab5ad64209efbe34135efc65e21b6a to your computer and use it in GitHub Desktop.
function testme() {
$classes = array(
'test',
'test2',
);
$class_array = '';
foreach ( $classes as $class ) {
$class_array .= $class . ' ';
}
$output = 'class="' . $class_array . '"';
echo $output;
// Echo = class="test test2 "
}
// Best way of removing trailing white space?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment