Skip to content

Instantly share code, notes, and snippets.

Avatar

Jani Gyllenberg nullthoughts

View GitHub Profile
@nullthoughts
nullthoughts / mergeJson.php
Created Jul 12, 2018
Laravel helper for merging two Json files matched by key value
View mergeJson.php
public static function mergeJson($to, $from, $matchBy, $key)
{
$to = json_decode(file_get_contents(storage_path($to)));
$from = json_decode(file_get_contents(storage_path($from)));
$values = [];
foreach($from as $object) {
$values[$object->{$matchBy}] = $object->{$key};
}