Skip to content

Instantly share code, notes, and snippets.

@zelon88
Last active July 4, 2016 02:08
Show Gist options
  • Save zelon88/cb0d54a175233f24543c8b246a32a2c4 to your computer and use it in GitHub Desktop.
Save zelon88/cb0d54a175233f24543c8b246a32a2c4 to your computer and use it in GitHub Desktop.
Display a div from a static webpage with PHP, no CuRL.
<?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