<?php
$matchesMatches =
function ($matches)
{
//$m = 1;
//yield $m;
// could put as a `for` so it is more optimized, but for now, that is premature optimization
foreach ($matches as $match) {
var_dump($match);
// yeild $m;
}
};
$matches = [1,2, 3];
$matches = [1 => array('a', 'b'), 2 => array('c', 'd'), 3 => array('e', 'f')];
foreach ($matchesMatches($matches) as $m) {
var_dump($m);
}
array(2) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
}
array(2) {
[0]=>
string(1) "c"
[1]=>
string(1) "d"
}
array(2) {
[0]=>
string(1) "e"
[1]=>
string(1) "f"
}
Warning: foreach() argument must be of type array|object, null given in /in/1Z7PR on line 18
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
array(2) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
}
array(2) {
[0]=>
string(1) "c"
[1]=>
string(1) "d"
}
array(2) {
[0]=>
string(1) "e"
[1]=>
string(1) "f"
}
Warning: foreach() argument must be of type array|object, null given in /in/1Z7PR on line 18