[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
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0

View File

@ -235,6 +235,19 @@ abstract class Formatting
return false; 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 * Render a plain text note content into HTML, extracting links and tags
*/ */