Created
April 5, 2019 10:27
-
-
Save mdjwel/e6cc900038c679be3cab9ac6355bee20 to your computer and use it in GitHub Desktop.
Here, I'm listing some functions that do string manipulation in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get a specific html tag from content | |
* @return a specific HTML tag from the loaded content | |
*/ | |
function rogan_get_html_tag( $tag = 'blockquote', $content = '' ) { | |
$dom = new DOMDocument(); | |
$dom->loadHTML($content); | |
$divs = $dom->getElementsByTagName( $tag ); | |
$i = 0; | |
foreach ($divs as $div) { | |
if($i == 1) { | |
break; | |
} | |
echo "<{$div->tagName}> {$div->nodeValue} </{$div->tagName}>"; | |
++$i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment