Why is this code returning null?
public function getPrice($crawler){
        $price = '';
            $crawler->filter('#j-sku-price')->each(
            function ($node) {
            $price = $node->text();
            });
return $price;
If I write it like this
public function getPrice($crawler){
        $price = '';
            $crawler->filter('#j-sku-price')->each(
            function ($node) {
            $price = $node->text();
                print($price);
            });
It works. But I want to return $price at the end.
 
    