I have a class GpsController
, in it I described the GPSOnline
method
At the exit, I should have:
[{"login":"199","ch":"1","poz":"99","la":"48.303017","lo":"38.041583"},{"login":"370","ch":"3","poz":"70","la":"48.297291","lo":"38.0153"},{"login":"399","ch":"3","poz":"99","la":"48.308815","lo":"38.02129"},{"login":"1209","ch":"1","poz":"209","la":"48.31639","lo":"37.964965"},{"login":"122","ch":"1","poz":"22","la":"48.338839","lo":"37.97747"},{"login":"3142","ch":"3","poz":"142","la":"48.305961","lo":"38.033485"},{"login":"1284","ch":"1","poz":"284","la":"48.34223","lo":"37.97"}]
Here is the method itself:
public function GPSOnline () { $gpsonline=File::get( Config::get('app.driverspath')); $fstep = explode("|", $gpsonline); foreach($fstep as $k => $v){ if(strlen($v)>0){ $sstep [] = explode(",", $v); } } $array = array(); foreach ($sstep as $v){ $tmp['ch'] = substr($v[0],0,1); $tmp['poz'] = substr($v[0],1); $tmp['la'] = $v[1]; $tmp['lo'] = $v[2]; $array[] = $tmp; } // echo json_encode($array); return Response::json(array($array)); }
But for some reason my code does not work. The controller is registered in the route, what is wrong?
return
afterreturn
: `Return Response :: json (array ($ array));` `$ validator = Validator :: make ($ array);` `$ messages = $ validator-> messages ();` - Opalosolo