[UTIL] Add Formatting::explode(array , string )

This commit is contained in:
Hugo Sales 2022-03-28 03:17:01 +01:00 committed by Diogo Peralta Cordeiro
parent dac94f53cd
commit 87e35716c1
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
1 changed files with 13 additions and 0 deletions

View File

@ -235,6 +235,19 @@ abstract class Formatting
return false;
}
/**
* Like \explode, but with multiple options for the delimiter. Will use the first one present
*/
public static function explode(array $separators, string $string)
{
foreach ($separators as $sep) {
if (str_contains($string, $sep)) {
return explode($sep, $string);
}
}
return $string;
}
/**
* Render a plain text note content into HTML, extracting links and tags
*/