1. Go to this page and download the library: Download val/one-to-many-iterator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// With an iterator
$aggregated = new OneToManyIterator('id', 'children', $result);
// With a generator
$aggregated = new OneToManyGenerator('id', 'children', $result);
foreach ($aggregated as $i => $parent) {
$parent['id'];
$parent['parent_column'];
foreach ($parent['children'] as $child) {
$child['child_column'];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.