Skip to content

Instantly share code, notes, and snippets.

@figital
Created January 28, 2011 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figital/801056 to your computer and use it in GitHub Desktop.
Save figital/801056 to your computer and use it in GitHub Desktop.
<?php
// Grab the raw data feed from the filesystem
$filename = "DHCP_Static.asp.html";
$file = file_get_contents($filename);
// Find the range of characters we'll scrape from the raw data feed
// Sure I could regex this part but I didn't :p
$startpos = strpos($file, "var table = new Array(") + 22;
$endpos = strpos($file, ");", $startpos);
$length = $endpos - $startpos;
// Scrape the file into a PHP var
$scrapeage = substr($file, $startpos, $length);
// Pull the semi-formatted data into a PHP array
$datalist = explode(",", $scrapeage);
// Calculate the total number of active DHCP leases
$numhosts = count($datalist) / 5;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment