Last active
July 4, 2016 02:08
-
-
Save zelon88/cb0d54a175233f24543c8b246a32a2c4 to your computer and use it in GitHub Desktop.
Display a div from a static webpage with PHP, no CuRL.
This file contains hidden or 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 | |
// / This file will load a static page and return a specified div. | |
// / The strings for $divStart and $divEnd must by IDENTICAL to the | |
// / way they are displayed in the $divLocation. | |
$divLocation = file_get_contents('http://somepage.com/somepage.html'); | |
$divStart = '{?><div id=whatever><?php}'; | |
$divEnd = '{something-unique-to-the-end-of-div-whatever}'; | |
$delimiter = '#'; | |
$divData = $delimiter . preg_quote($divStart, $delimiter) | |
. '(.*?)' | |
. preg_quote($divEnd, $delimiter) | |
. $delimiter | |
. 's'; | |
preg_match($divData,$divLocation,$div1); | |
$div = $div1[0]; | |
// / Look ma, no CuRL! | |
echo $div; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment