Get result view with formatter programmattically Example a view with show fields:



I want retrive array result like this:

[
  [title,
   date_start
   data_end
   ...
  ]
]
Use $view-&gt;result to get the filtered rows, $view-field for the fields, on which you can use the methods getValue() for the field value and render() for the formatted field as render array.

An example:

use Drupal\views\Views;

  $values = [];
  $view = views::getview('view_example');
  if ($view) {
    $view-&gt;execute();
    foreach ($view-&gt;result as $rid =&gt; $row) {
      foreach ($view-&gt;field as $fid =&gt; $field ) {
        $values[$rid][$fid . '-value'] = $field-&gt;getValue($row);
        $values[$rid][$fid . '-render'] = $field-&gt;render($row);
      }
    }
  }