久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<small id='7YYKT'></small><noframes id='7YYKT'>

    • <bdo id='7YYKT'></bdo><ul id='7YYKT'></ul>
    <i id='7YYKT'><tr id='7YYKT'><dt id='7YYKT'><q id='7YYKT'><span id='7YYKT'><b id='7YYKT'><form id='7YYKT'><ins id='7YYKT'></ins><ul id='7YYKT'></ul><sub id='7YYKT'></sub></form><legend id='7YYKT'></legend><bdo id='7YYKT'><pre id='7YYKT'><center id='7YYKT'></center></pre></bdo></b><th id='7YYKT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7YYKT'><tfoot id='7YYKT'></tfoot><dl id='7YYKT'><fieldset id='7YYKT'></fieldset></dl></div>
    1. <legend id='7YYKT'><style id='7YYKT'><dir id='7YYKT'><q id='7YYKT'></q></dir></style></legend>
      <tfoot id='7YYKT'></tfoot>

        在 UTF-8 編碼的字符串上使用 str_split

        Using str_split on a UTF-8 encoded string(在 UTF-8 編碼的字符串上使用 str_split)

          <small id='24vnV'></small><noframes id='24vnV'>

          <i id='24vnV'><tr id='24vnV'><dt id='24vnV'><q id='24vnV'><span id='24vnV'><b id='24vnV'><form id='24vnV'><ins id='24vnV'></ins><ul id='24vnV'></ul><sub id='24vnV'></sub></form><legend id='24vnV'></legend><bdo id='24vnV'><pre id='24vnV'><center id='24vnV'></center></pre></bdo></b><th id='24vnV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='24vnV'><tfoot id='24vnV'></tfoot><dl id='24vnV'><fieldset id='24vnV'></fieldset></dl></div>

            • <legend id='24vnV'><style id='24vnV'><dir id='24vnV'><q id='24vnV'></q></dir></style></legend>
                <tbody id='24vnV'></tbody>
              <tfoot id='24vnV'></tfoot>
                  <bdo id='24vnV'></bdo><ul id='24vnV'></ul>
                  本文介紹了在 UTF-8 編碼的字符串上使用 str_split的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我目前正在處理一個項目,我想我應該繼續學習如何使用 PDO,而不是使用常規的 MySQL 查詢.

                  I'm currently working on a project, and instead of using regular MySQL queries I thought I'd go ahead and learn how to use PDO.

                  我有一個表叫參賽者,數據庫、表和所有的列都是utf-8.我在參賽者表中有十個條目,它們的名稱"列包含 ??? 等字符.

                  I have a table called contestants, both the database, the table, and all of the columns are in utf-8. I have ten entries in the contestant table, and their column "name" contains characters such as ???.

                  現在,當我從數據庫中獲取一個條目并使用 var_dump 名稱時,我得到了一個很好的結果,一個包含所有特殊字符的字符串.但我需要做的是將字符串按字符拆分,將它們放入一個數組中,然后再進行洗牌.

                  Now, when I fetch an entry from the database, and var_dump the name, I get a good result, a string with all the special characters intact. But what I need to do is to split the string by characters, to get them in an array that I then shuffle.

                  例如,我有這個字符串:測試 ??? T??n

                  For instance, I have this string: Test ??? T??n

                  當我運行 str_split 時,我將每個字符放入數組中它自己的鍵中.唯一的問題是所有特殊字符都顯示為: ,意味著數組將如下所示:

                  And when I run str_split I get each character in it's own key in an array. The only issue is that all the special characters display as this: ?, meaning the array will be like this:

                  Array
                  (
                      [0] => T
                      [1] => e
                      [2] => s
                      [3] => t
                      [4] =>  
                      [5] => ?
                      [6] => ?
                      [7] => ?
                      [8] => ?
                      [9] => ?
                      [10] => ?
                      [11] =>  
                      [12] => T
                      [13] => ?
                      [14] => ?
                      [15] => ?
                      [16] => ?
                      [17] => n
                  )
                  

                  如您所見,它不僅會弄亂字符,還會在 str_split 過程中復制它們.我嘗試了幾種拆分字符串的方法,但它們都有相同的問題.當我在拆分之前輸出字符串時,它顯示特殊字符就好了.

                  As you can see, it not only messes up the characters, but it also duplicates them in str_split process. I've tried several ways to split the string, but they all have the same issue. When I output the string before the split, it shows the special characters just fine.

                  這是我的 dbConn.php 代碼:

                  This is my dbConn.php code:

                  //需要配置文件:require_once('config.inc.php');

                  // Require config file: require_once('config.inc.php');

                  // Start PDO connection:
                  $dbHandle = new PDO("mysql:host=$dbHost;dbname=$dbName;charset=utf-8", $dbUser, $dbPass);
                  $dbHandle -> exec("SET CHARACTER SET utf8");
                  
                  // Set error reporting:
                  $dbHandle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
                  

                  這是我用來從數據庫中獲取并循環的代碼:

                  And this is the code that I use to fetch from the database and loop:

                  // Require files:
                  require_once('dbConn.php');
                  
                  // Get random artist:
                  $artist = $dbHandle->query("SELECT * FROM ".ARTIST_TABLE." WHERE id = 11 ORDER BY RAND() LIMIT 1");
                  $artist->setFetchMode(PDO::FETCH_OBJ);
                  $artist = $artist->fetch();
                  var_dump($artist->name);
                  
                  // Split name:
                  $artistChars = str_split($artist->name);
                  

                  我使用 utf-8 連接,我的 php 文件是 utf-8 沒有 BOM 并且此頁面上沒有其他特殊字符共享此問題.可能有什么問題,或者我做錯了什么?

                  I'm connecting with utf-8, my php file is utf-8 without BOM and no other special characters on this page share this issue. What could be wrong, or what am I doing wrong?

                  推薦答案

                  str_split 不適用于 multi-byte 字符,它只會返回第一個字節 - 從而使您的字符無效.你可以使用 mb_split.

                  這篇關于在 UTF-8 編碼的字符串上使用 str_split的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  • <bdo id='TZ6P6'></bdo><ul id='TZ6P6'></ul>
                      <tbody id='TZ6P6'></tbody>
                  • <tfoot id='TZ6P6'></tfoot>
                        1. <i id='TZ6P6'><tr id='TZ6P6'><dt id='TZ6P6'><q id='TZ6P6'><span id='TZ6P6'><b id='TZ6P6'><form id='TZ6P6'><ins id='TZ6P6'></ins><ul id='TZ6P6'></ul><sub id='TZ6P6'></sub></form><legend id='TZ6P6'></legend><bdo id='TZ6P6'><pre id='TZ6P6'><center id='TZ6P6'></center></pre></bdo></b><th id='TZ6P6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TZ6P6'><tfoot id='TZ6P6'></tfoot><dl id='TZ6P6'><fieldset id='TZ6P6'></fieldset></dl></div>

                          • <legend id='TZ6P6'><style id='TZ6P6'><dir id='TZ6P6'><q id='TZ6P6'></q></dir></style></legend>

                            <small id='TZ6P6'></small><noframes id='TZ6P6'>

                            主站蜘蛛池模板: 免费观看一级毛片视频 | 成人免费在线播放视频 | www.久久影视| 日韩精品免费看 | 日日夜夜精品免费视频 | 欧美日韩视频在线 | 国产成人免费视频 | 国产成人精品一区二区三区四区 | 一区二区三区在线播放 | 国产精品一区二区在线播放 | 99re视频在线观看 | 精品久久亚洲 | 久久精品 | 久久精品毛片 | 91成人免费看片 | 国产视频黄色 | 欧美偷偷操| 成人av播放 | 国产一区二区视频在线观看 | 国产又爽又黄的视频 | 国产精品久久久久久久久久 | 国产这里只有精品 | 国产特一级黄色片 | www.久久| 日韩高清一区 | 精品熟人一区二区三区四区 | 亚洲精品久久 | 99re热精品视频国产免费 | 国产三级精品三级在线观看四季网 | 国产精品综合一区二区 | 成人免费视频观看视频 | 国产精品精品视频一区二区三区 | 91麻豆精品国产91久久久久久 | 日韩欧美在线一区 | 毛片免费视频 | 国产性色视频 | 日韩有码在线观看 | 成年免费大片黄在线观看一级 | 成人午夜免费视频 | 91原创视频在线观看 | 91青娱乐在线 |