php常用字串處理

來源:互聯網
上載者:User

標籤:ar   sp   div   on   art   bs   ad   ef   nbsp   

<?php/** * Created by PhpStorm. * User: tang * Date: 14-11-16 * Time: 下午2:19 *///把字串轉成數組。$string = "fafa.afaf.fsfs.342.4fw3.x";$arr = explode(‘.‘,$string);    //以點為單位,轉成數組。var_dump($arr); $count = count($arr);var_dump($count);      // count() 這是系統的一個函數,計算數量的。 $art = $arr[$conut-1];  // 查看,數組中最後一個單元的值。var_dump($art); //把數組變成字串$arr = array(1,3,4,‘d‘,‘d‘,‘4d‘);echo implode(‘,‘,$arr),‘<br/>‘;   //將數組的值,邊接成一個數符串。按‘,’號為標記。 //截取$string = "abcdefg";echo substr($string,-3,1),‘<br/>‘;   // 函數內部參數  第一個參數,代表著,起點,正數是從字串左到右,負數是 尾部向左數起。第二參數,代表著,數幾位。。注意字串數,從0位開始的。 //替換$string = ‘fafa.fafda.eiakf.3ad.4d‘;echo str_replace(‘.‘,‘*‘,$string);    //函數()第一個參數,是標記,第二個參數,是要替換的目標,第三個參數,就是對應字串的變數 //重複輸出$str = ‘abc‘;echo str_repeat($str,10);    // 函數() 第一個參數,對應重複的字串變數。 第二個參數是,重複的次數。

php常用字串處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.