Is it recommended to render data in the view or the controller in PHP?

It is recommended to render data in the view rather than the controller in PHP in order to separate concerns and maintain a clean and organized codebase. The controller should handle the logic and data manipulation, while the view should be responsible for displaying the data to the user.

// Controller
$data = fetchDataFromDatabase();
include 'view.php';

// View
foreach ($data as $item) {
    echo $item['name'];
}