diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1fb83e84022..d1ea43af5d1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11851,6 +11851,25 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') return array(); } +/** + * Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) + * + * @param string $input String to explode + * @return array Array of string values + */ +function dolExplodeKeepIfQuotes($input) +{ + // Use regexp to capture words and section in quotes + $matches = array(); + preg_match_all('/"([^"]*)"|\'([^\']*)\'|(\S+)/', $input, $matches); + + // Merge result and delete empty values + // @phan-suppress-next-line PhanPluginUnknownClosureParamType + return array_filter(array_map(function ($a, $b, $c) { + return $a ?: ($b ?: $c); + }, $matches[1], $matches[2], $matches[3])); +} + /** * Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag) @@ -11881,26 +11900,6 @@ function dol_getmypid() } } - -/** - * Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) - * - * @param string $input String to explode - * @return array Array of string values - */ -function dolExplodeKeepIfQuotes($input) -{ - // Use regexp to capture words and section in quotes - $matches = array(); - preg_match_all('/"([^"]*)"|\'([^\']*)\'|(\S+)/', $input, $matches); - - // Merge result and delete empty values - return array_filter(array_map(function ($a, $b, $c) { - // @phan-suppress-current-line PhanPluginUnknownClosureParamType - return $a ?: ($b ?: $c); - }, $matches[1], $matches[2], $matches[3])); -} - /** * Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) *