當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TextFormat::tokenize方法代碼示例

本文整理匯總了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 = "`";
//.........這裏部分代碼省略.........
開發者ID:legoboy0215,項目名稱:LegionPE-Theta-Base,代碼行數:101,代碼來源:MUtils.php


注:本文中的pocketmine\utils\TextFormat::tokenize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。