pianello-api/app/Http/Helpers.php
Ale Gallo b91cf0cbde Committing laravel + api (part 1)
committing part of the laravel system with templating files and api implementation.
2023-11-10 15:54:41 +01:00

36 lines
1.1 KiB
PHP

<?php
if (!function_exists('merge')) {
function merge($arrays)
{
$result = [];
foreach ($arrays as $array) {
if ($array !== null) {
if (gettype($array) !== 'string') {
foreach ($array as $key => $value) {
if (is_integer($key)) {
$result[] = $value;
} elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
$result[$key] = merge([$result[$key], $value]);
} else {
$result[$key] = $value;
}
}
} else {
$result[count($result)] = $array;
}
}
}
return join(" ", $result);
}
}
if (!function_exists('uncamelize')) {
function uncamelize($camel, $splitter = "_")
{
$camel = preg_replace('/(?!^)[[:upper:]][[:lower:]]/', '$0', preg_replace('/(?!^)[[:upper:]]+/', $splitter . '$0', $camel));
return strtolower($camel);
}
}