Files
Fritz Ramirez 10d0c477c8 Initial commit
2024-02-12 22:54:20 -05:00

71 lines
1.8 KiB
PHP

<?php
if (!function_exists('currencySymbol')) {
function currencySymbol() {
if(app('user_currency') != null){
return app('user_currency')->symbol;
}
if(app('general_setting')->currency_symbol != null){
return app('general_setting')->currency_symbol;
}else {
return '$ ';
}
}
}
if (!function_exists('array_keys_to_snake_case')) {
// Convert camel case array keys to snake case array keys
function array_keys_to_snake_case($arr) {
return array_combine(array_map(function($key) {
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $key));
}, array_keys($arr)), $arr);
}
}
if (!function_exists('array_keys_to_camel_case')) {
function array_keys_to_camel_case($arr) {
$result = [];
foreach ($arr as $key => $value) {
$nkey = lcfirst(str_replace('_', '', ucwords($key, '_')));
if (is_array($value)) {
$value = array_keys_to_camel_case($value);
}
$result[$nkey] = $value;
}
return $result;
}
}
if (!function_exists('array_to_object')) {
function array_to_object($arr) {
if (!is_array($arr)) {
return $arr;
}
$result = new \stdClass();
foreach ($arr as $key => $value) {
$result->$key = array_to_object($value);
}
return $result;
}
}
if (!function_exists('substr_text_only')) {
function substr_text_only($string, $limit, $end='...')
{
$with_html_count = strlen($string);
$without_html_count = strlen(strip_tags($string));
$html_tags_length = $with_html_count-$without_html_count;
return Str::limit($string, $limit+$html_tags_length, $end);
}
}