To limit results, just use a global counter variable, increment each time in myRecordHandler and return TRUE when it equals the limit you want. To extract the MEDIUM image each time, the best structure in this instance would be a loop, and then break out of the loop when the -NAME attribute is "medium" (or whichever required). For example:
<?php require("MagicParser.php"); $counter = 0; function myRecordHandler($record) { global $counter; $i = 0; $postfix = ""; while(1) { if ($i) $postfix = "@".$i; // make sure we don't have an infinate loop if (!isset($record["SIZES/SIZE".$postfix])) break; if ($record["SIZES/SIZE".$postfix."-NAME"]=="medium") { $imageURL = $record["SIZES/SIZE".$postfix]; break; } $i++; } // medium image URL will be in $imageURL here! $counter++; if ($counter == 5) return TRUE; } MagicParser_parse("{link saved}","myRecordHandler","xml|LFM/IMAGES/IMAGE/"); ?>
Hello Ron,
To limit results, just use a global counter variable, increment each time in myRecordHandler and return TRUE when it equals the limit you want. To extract the MEDIUM image each time, the best structure in this instance would be a loop, and then break out of the loop when the -NAME attribute is "medium" (or whichever required). For example:
<?php
require("MagicParser.php");
$counter = 0;
function myRecordHandler($record)
{
global $counter;
$i = 0;
$postfix = "";
while(1)
{
if ($i) $postfix = "@".$i;
// make sure we don't have an infinate loop
if (!isset($record["SIZES/SIZE".$postfix])) break;
if ($record["SIZES/SIZE".$postfix."-NAME"]=="medium")
{
$imageURL = $record["SIZES/SIZE".$postfix];
break;
}
$i++;
}
// medium image URL will be in $imageURL here!
$counter++;
if ($counter == 5) return TRUE;
}
MagicParser_parse("{link saved}","myRecordHandler","xml|LFM/IMAGES/IMAGE/");
?>
Hope this helps!
Cheers,
David.