Skip to content

Instantly share code, notes, and snippets.

@danalmeida
Last active December 18, 2015 14:49
Show Gist options
  • Save danalmeida/5799721 to your computer and use it in GitHub Desktop.
Save danalmeida/5799721 to your computer and use it in GitHub Desktop.
Adds a class to the first instance of the specified HTML element.
<?php preg_replace('/<p([^>]+)?>/', '<p$1 class="first">', $content, 1); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment