You are here:  » Basic File Analysis

Basic File Analysis

This example shows a very simple file analysis script that can be used to determine what format string to use for a given source file and what field names are contained within the associative array passed to your record handler function for each record. Just like the demo script on this website it uses PHP's foreach construct to loop through each field in $record.

Assuming that autodetection is successful this demo just displays the contents of the first record in the source file. Click here to view the live output from this script. Remember that you could change $filename to be anything you like, such as the path to a local file rather than an Internet URL (an RSS feed in this example).

header("Content-Type: text/plain");

$url "";
"URL: ".$url."\n\n";
$formatString MagicParser_getFormat($url);
"Format String: ".$formatString."\n\n";