I create each
$categories = array();
$crawler
->filter('.am-filter-items-attr_category_ids')
->each(function ($node) use ($client) {
$node->filter('ul > li ')->each(function ($level2) {
$name_one = $level2->text();
$level2->filter(' ul > li > a')->each(function ($level3) {
$href = $level2->extract(array('href'));
$categories[] = array('cat' => $href[0],
'Cat_name' => $name_one);
}
}
}
and I get a error Undefined variable: name_one
I need to create an array, how do I pass a variable inside another loop? So that there are no mistakes?
CodePudding user response:
You forgot to add this variable to last function.
Change ->each(function ($level3) {
to ->each(function ($level3) use ($name_one) {