php explode split str_split函數區別與執行個體_PHP教程

來源:互聯網
上載者:User
php教程 explode split str_split函數區別與執行個體

三個函數都是把一個字串分割成一個數組,但各有各的用法,下面我們就一一來看關於php explode split str_split函數區別與執行個體吧。
*/
$str ="id_99_cn.html";
$array = explode('_',$str);
print_r($array);
/*
array
(
[0] => id
[1] => 99
[2] => cn.html
)
*/

//函數原型:array split (string $pattern, string $string [, int $limit])

$split = split('_',$str);
print_r($split);
/*
array
(
[0] => id
[1] => 99
[2] => cn.html
)
*/

//str_split() 函數的字串分割成一個數組。

$str_split = str_split($str,2);
print_r($str_split);
/*
array
(
[0] => id
[1] => _9
[2] => 9_
[3] => cn
[4] => .h
[5] => tm
[6] => l
)

本站原創文章轉載註明來源於http://www.bKjia.c0m

http://www.bkjia.com/PHPjc/631358.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631358.htmlTechArticlephp教程 explode split str_split函數區別與執行個體 三個函數都是把一個字串分割成一個數組,但各有各的用法,下面我們就一一來看關於php expl...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.