$r = require 'application/config/routes.php';
<?php
return [
'' => [
'controller' => 'main',
'action' => 'index',
],
];
$file = '/path/to/file.php';
$array = [];
if (file_exists($file)){
$array = include($file);
}
$array['new_value'] = 'FooBar!!!';
$content = var_export($array, true);
file_put_contents($file, '<?php return ' . $content.';');