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:
30
lib/util.php
30
lib/util.php
@@ -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.
|
||||
|
Reference in New Issue
Block a user