Created
December 4, 2013 16:23
-
-
Save tonykwon/7790503 to your computer and use it in GitHub Desktop.
Extracting iframes from html content
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 | |
// $buffer contains the HTML generated | |
$extracted = array(); | |
$pattern = "#<iframe[^>]+>.*?</iframe>#is"; | |
preg_match_all($pattern, $buffer, $matches); | |
if ( $matches ) { | |
foreach($matches as $match) { | |
$buffer = strtr($buffer, array($match[0] => '')); | |
$extracted[] = $match[0]; | |
} | |
} | |
if ( $extracted ) { | |
// we have iframe snippets from the html buffer | |
// do something with these | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment