當前位置: 首頁> 函數類別大全> str_split

str_split

將字符串轉換為數組
名稱:str_split
分類:字符串
所屬語言:php
一句話介紹:把字符串分割到數組中。

實例

例子2

把字符串"Shanghai" 分割到數組中:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token function">print_r</span> <span class="token punctuation">(</span> <span class="token function">str_split</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"Shanghai"</span> <span class="token punctuation">)</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

例子2

使用length參數:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token function">print_r</span> <span class="token punctuation">(</span> <span class="token function">str_split</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"Shanghai"</span> <span class="token punctuation">,</span> <span class="token number">3</span> <span class="token punctuation">)</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

同類函數
  • 計算指定字符串在目標字符串中最後一次出現的位置 strrpos

    strrpos

    計算指定字符串在目標字符串中最後一次出現
  • 重複一個字符串 str_repeat

    str_repeat

    重複一個字符串
  • 對字符串執行rot13轉換 str_rot13

    str_rot13

    對字符串執行rot13轉換
  • 設置區域設置信息 setlocale

    setlocale

    設置區域設置信息
  • 將字符串轉化為小寫 strtolower

    strtolower

    將字符串轉化為小寫
  • 在字符串所有新行之前插入HTML 換行標記 nl2br

    nl2br

    在字符串所有新行之前插入HTML換行標記
  • 使用反斜線轉義字符串 addslashes

    addslashes

    使用反斜線轉義字符串
  • 查詢語言和區域設置信息 nl_langinfo

    nl_langinfo

    查詢語言和區域設置信息
熱門文章