本文整理匯總了PHP中pocketmine\utils\TextFormat::tokenize方法的典型用法代碼示例。如果您正苦於以下問題:PHP TextFormat::tokenize方法的具體用法?PHP TextFormat::tokenize怎麽用?PHP TextFormat::tokenize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\utils\TextFormat
的用法示例。
在下文中一共展示了TextFormat::tokenize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: toMd
public static function toMd($string)
{
if (!\is_array($string)) {
$string = TextFormat::tokenize($string);
}
$newString = "";
$tokens = 0;
$close = "";
foreach ($string as $token) {
switch ($token) {
case TextFormat::BOLD:
$newString .= $close . "**";
$close = "**";
++$tokens;
break;
case TextFormat::OBFUSCATED:
$newString .= $close . "~~";
$close = "~~";
++$tokens;
break;
case TextFormat::ITALIC:
$newString .= $close . "_";
$close = "_";
++$tokens;
break;
case TextFormat::UNDERLINE:
$newString .= $close;
$close = "";
++$tokens;
break;
case TextFormat::STRIKETHROUGH:
$newString .= $close . "~~";
$close = "~~";
++$tokens;
break;
case TextFormat::RESET:
$newString .= $close;
$close = "";
$tokens = 0;
break;
//Colors
//Colors
case TextFormat::BLACK:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::DARK_BLUE:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::DARK_GREEN:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::DARK_AQUA:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::DARK_RED:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::DARK_PURPLE:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::GOLD:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::GRAY:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::DARK_GRAY:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::BLUE:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::GREEN:
$newString .= $close . "`";
$close = "`";
++$tokens;
break;
case TextFormat::AQUA:
$newString .= $close . "`";
$close = "`";
//.........這裏部分代碼省略.........