$crawler = new Crawler($xml);
$parkList = [];
$crawler->filter('wfs|FeatureCollection > gml|featureMember > bm|ST_PARK_P > bm|NOM')->each(function (Crawler $actualPark, $i) {
$parkList[$i] = [];
$parkList[$i][] = $actualPark->text();
//var_dump($parkList); // $parklist variable is filled
});
$crawler->filter('wfs|FeatureCollection > gml|featureMember > bm|ST_PARK_P > bm|geometry > gml|Point > gml|pos')->each(function (Crawler $actualPark, $i) {
$parkList[$i][] = explode(' ', $actualPark->text())[0];
});
$crawler->filter('wfs|FeatureCollection > gml|featureMember > bm|ST_PARK_P > bm|geometry > gml|Point > gml|pos')->each(function (Crawler $actualPark, $i) {
$parkList[$i][] = explode(' ', $actualPark->text())[1];
});
return $parkList; //parklist variable is strangely empty
Why my parkList variable is empty outside the .each function whereas I declared it outside the loop and fill its value during the loop... and the loop is successfully executed ?