What you need to do is instead of displaying each record in myRecordHandler(), add the record to a global array ($records), and then after the parse shuffle the $records array, and display with your original myRecordHandler using a foreach loop. For example:
<?php function myDisplayRecordHandler($record) { // exactly as your original myRecordHandler } function myRecordHandler($record) { global $records; $records[] = $record; } $records = array(); MagicParser_parse("filename.xml","myRecordHandler","xml|FORMAT/STRING/"); shuffle($records); foreach($records as $record) { myDisplayRecordHandler($record): } ?>
Hi,
What you need to do is instead of displaying each record in myRecordHandler(), add the record to a global array ($records), and then after the parse shuffle the $records array, and display with your original myRecordHandler using a foreach loop. For example:
<?php
function myDisplayRecordHandler($record)
{
// exactly as your original myRecordHandler
}
function myRecordHandler($record)
{
global $records;
$records[] = $record;
}
$records = array();
MagicParser_parse("filename.xml","myRecordHandler","xml|FORMAT/STRING/");
shuffle($records);
foreach($records as $record)
{
myDisplayRecordHandler($record):
}
?>
Hope this helps!
Cheers,
David.