You are here:  » return multiple values


return multiple values

Submitted by GeXus on Sat, 2007-03-17 20:24 in

I'm using the count to limit the number of times I want to loop through the feed, however I also need to return the records, so i can assign them to a smarty variable. Any idea how I can do this?

Submitted by support on Sun, 2007-03-18 08:44

Hi,

Again you want to use a global variable to do this, but remember that you will have to load the records into an array of array's otherwise you will only have access to the last record. The basic method is as follows:

<?php
  
// create a global array to hold the records
  
$records = array();
  function 
myRecordHandler($record)
  {
    
// add the record to the global array
    
global $records;
    
$records[] = $record;
  }
  
// parse as usual
  
MagicParser_parse("file.xml","myRecordHandler");
  
// after parsing, all records are in $records array
?>

Hope this helps!
Cheers,
David.