"Array To String Conversion Error" When Trying To Get The Values Of Fields

I'm trying to make datatables as server-side processing. It somehow worked. I wanted to pass the fields to ajax file and use them to get the data. I made the fields name as a string to divide them using a delimiter character. Then I passed the string and get it and made them as an array. Problem is, "Array to string conversion error" displays when I try to get the values through them.

PHP block in October CMS


function onStart()
    $this['tableName'] = 'BYAPPS_apps_data';
    $this['fields'] = "app_id|app_name|app_ver|byapps_ver";

Javascript in October CMS(same page as the php block)

  var table = $('#' + tableId).DataTable( {
      processing: true,
      serverSide: true,
      ajax: {
          url: '/ajax?tb={{ tableName|raw() }}&fd={{ fields|raw() }}',
          type: 'GET',
          error: function(e) {
      paging: true,
      pageLength: 50,

Ajax page

function onStart()
   $table = $_GET['tb'];
   $length = $_GET['length'];
   $start = $_GET['start'];
   $fields = explode("|", $_GET['fd']);

   $result = DB::table($table)->skip($start)->limit($length)->get();
   $data = array();

   foreach($result as $row) {
      $sub_array = array();

      for ($i = 0; $i < count($fields); $i++) {

        echo "<script>console.log('".$fields[$i]."')</script>";
        $sub_array[] = $row->$fields[$i];

      $data[] = $sub_array;

The $fields[$i] shows 'app_id', 'app_name'... But I don't know why I can't get the values through like this. $row->$fields[$i] How can I fix this?

$result contains these kinda data like below.

object(October\Rain\Support\Collection)#947 (1) { ["items":protected]=> array(50) { [0]=> object(stdClass)#949 (88) { ["idx"]=> int(1) ["o_idx"]=> int(0) ["mem_id"]=> string(20) "[email protected]" ["app_id"]=> string(10) "epicegirls" ["recom_id"]=> string(6) "byapps" ["app_cate"]=> string(2) "01" ["app_process"]=> int(8) ["app_name"]=> string(12) "에피스걸" ["service_type"]=> string(3) "biz" ["server_group"]=> string(1) "2" ["apps_type"]=> string(19) "안드로이드+iOS" ["app_os_type"]=> string(7) "android" ["byapps_ver"]=> string(3) "2.1" ["app_ver"]=> string(3) "1.6" ["app_ver_ios"]=> string(3) "1.1" ["app_build"]=> string(0) "" ["app_build_ios"]=> string(0) "" ["app_lang"]=> string(2) "ko" ["packagename"]=> NULL ["bundleid"]=> NULL ["app_android_url"]=> string(66) "" ["app_ios_url"]=> string(58) "" ["app_icon"]=> string(14) "1366951826.png" ["noti_gcm"]=> string(39) "AIzaSyB4uXkiTltMx3yjQNo26uyfpopMB8vpd94" ["noti_ios"]=> string(14) "1369015681.pem" ["noti_gcm_num"]=> NULL ["noti_fcm_num"]=> NULL ["noti_ios_cerp"]=> string(10) "byapps2013" ["push_server"]=> string(7) "default" ["developer_account"]=> string(1) "N" ["developer_info"]=> string(2580) "- 개발자아이디: 


Try this

$sub_array[] = $row->{$fields[$i]};