vendredi 27 novembre 2015

Php global variable to param-function

I am can't use variable $data in inner function:

$data = array(...);
Excel::create('Filename',function($excel){
  foreach($data as $v){
     //...
  }
});

I get error: "Undefined variable: $data"

Also:

 $data = array(...);
 Excel::create('Filename',function($excel){
   global $data;
   foreach($data as $v){
      //...
   }
 });

I get error "Invalid argument supplied for foreach()"

How I can use $data in function?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Imlxqu
via IFTTT

Aucun commentaire:

Enregistrer un commentaire