I am using "fabpot/goutte": "^4.0",.
I am trying to get from the site the date and the release in an array.
Please find my runnable example:
<?php
require_once '../vendor/autoload.php';
use Symfony\Component\DomCrawler\Crawler;
use Goutte\Client;
try {
$resArr = array();
$tempArr = array();
$url = "https://www.steelcitycollectibles.com/product-release-calendar";
// get page
$client = new Client();
$content = $client->request('GET', $url)->html();
$crawler = new Crawler($content, null, null);
$table = $crawler->filter('#schedule'); //->first()->closest('table');
$index = 0;
$resArr = array();
$table->filter('div')
->each(function (Crawler $tr) use (&$index, &$resArr) {
if ($tr->filter('.schedule-date')->count() > 0) {
$releaseDate = $tr->filter('.schedule-date')->text();
}
if ($tr->filter('div > div.eight.columns > a')->count() > 0) {
$releaseStr = $tr->filter('div > div.eight.columns > a')->text();
array_push($resArr, [$releaseDate, $releaseStr]);
}
});
var_dump($resArr);
} catch (Exception $e) {}
However, I do not get for each item the correct date:
For the null values I would like to add the correct date. In this case 12/20/21.

Assuming you want to apply the most recently seen date to each element of the array, you simply need to set a default and then update it within the loop. This will have to be another pass by reference since the anonymous function state is reset on each pass.
Output:
As a side note, the documentation for Goutte says the
request()method returns aCrawlerobject. You're needlessly pulling out the HTML and creating aCrawlerobject manually. Change your code to this: