I don't understand yield PHP very well.... all the examples online are not useful examples.
For example in my web app, actually, to create a GUI of results get by a function I use:
<?php
function get_results_from_database($id) {
//connect to database
//omitted
return $array_results; //it is an array
}
Now my html page is like it:
<html>
<body>
<div>
<?php
$res = get_results_from_database(5); // for example it returns 1.000 rows
foreach ( $res as $index => $row ) {
echo '<p>' . $row['Name'] . '</p>';
}
echo '<p>TOTAL ROWS: ' . count($res) . '</p>';
?>
</div>
A code like this can be converted with a yield approach? I don't understand the sense of it.... if the yield is used to async request, no sense to use it for creating graphical HTML pages...or I missing some things?
Where I can find a useful example of a yield approach?