RecordSet::foreach - jcobban/Genealogy GitHub Wiki

foreach($recordSet as $key => $record)

Up: class RecordSet

The most common way to look at the set of Records represented by a RecordSet is to iterate over them using a foreach statement. If $set->getInformation()['prime'] is a field name, then the index is the value of that field, otherwise it is a sequential integer. Note that, unlike with an array, you cannot iterate over the set using the reset(), current(), next(), prev(), and end() functions. Nor can you iterate over the record set using for($i=0; $i<count($recordSet); $i++) if the RecordSet has a primary key. You also cannot use any of the functions whose names start with array_ such as array_key_exists.

Examples:

$set		= new RecordSet('Names', array('surname' => 'Smith'));
print "There are " . $set->count() . " Smiths. \n";
foreach($set as $idnx => $name)
{
	print "IDNX=" . $idnx . ", ";
	print "Given Name=" . $name->get('givenname') . "\n";
}

Next: $recordset[$key]