api - PHP return array when scraping with Goutte -


i'm trying return array of items goutte, can print them out want them in array, api. here's sample code. i'm using laravel 5.1.

public function index() {     $posts = array();     $client = new client();     $crawler = $client->request('get', 'http://www.icetimux.com');      $crawler->filter('h2 > a')->each(function ($node) use ($posts){         // print $node->text(); //this prints them, needs return array :(         array_push($posts, $node->text());     });     return $posts; } 

all empty array.

haha! did it! check out!

public function index() {     $client = new client();     $crawler = $client->request('get', 'http://www.icetimux.com');      return $result = $crawler->filter('h2 > a')->each(function ($node){         return $posts[] = $node->text();     }); } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -