Skip to content

Instantly share code, notes, and snippets.

View nullthoughts's full-sized avatar

Jani Gyllenberg nullthoughts

View GitHub Profile
@nullthoughts
nullthoughts / str_between.php
Last active August 23, 2018 13:27
PHP function to return string between two strings
/**
* Get the portion of a string between two given strings.
*
* @param string $subject
* @param string $start
* @param string $end
* @param bool $insensitive
* @param bool $innerOnly
* @param bool $inverse
*
@nullthoughts
nullthoughts / vueImplode.js
Created August 3, 2018 18:53
Vue Implode Method (Join on Array Key)
implode(array, key = null, glue = ', ') {
if(key) {
array = array.map(function(element) {
return element[key];
})
}
return array.join(glue);
},
@nullthoughts
nullthoughts / mergeJson.php
Created July 12, 2018 19:54
Laravel helper for merging two Json files matched by key value
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};
}