1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

Ridistribuzione funzioni generiche

This commit is contained in:
Thomas Zilio
2018-07-17 12:05:21 +02:00
parent f13bdc306c
commit 3eefce1ee9
16 changed files with 524 additions and 475 deletions

View File

@@ -2,6 +2,12 @@
use Stringy\Stringy as S;
/*
* Funzioni esterne di utilità per il progetto.
*
* @since 2.3
*/
if (!function_exists('array_column')) {
/**
* Pluck an array of values from an array.
@@ -53,6 +59,30 @@ if (!function_exists('ends_with')) {
}
}
if (!function_exists('str_replace_once')) {
/**
* Sostituisce la prima occorenza di una determinata stringa.
*
* @param string $str_pattern
* @param string $str_replacement
* @param string $string
*
* @since 2.3
*
* @return string
*/
function str_replace_once($str_pattern, $str_replacement, $string)
{
if (strpos($string, $str_pattern) !== false) {
$occurrence = strpos($string, $str_pattern);
return substr_replace($string, $str_replacement, strpos($string, $str_pattern), strlen($str_pattern));
}
return $string;
}
}
if (!function_exists('str_contains')) {
/**
* Check if a string contains the given string.