Skip to content

Instantly share code, notes, and snippets.

View takifouhal's full-sized avatar

takifouhal takifouhal

View GitHub Profile
@takifouhal
takifouhal / persist_configuration_laravel.php
Last active September 18, 2019 14:05
persist config changes in laravel
function set_deep_index_value(&$data,$data_indexes,$new_value){
foreach ($data_indexes as $index){
if($index == sizeof($data_indexes)-1) $data[$index]=$new_value;
else return set_deep_index_value($data[$index],array_slice($data_indexes,1),$new_value);
}
}
function persist_config($target,$new_value = null) {
if(is_array($target) && sizeof($target) == 1){
$new_value = array_values($target)[0];