substr_replace()函數:將手機號中間4位隱藏為*號

來源:互聯網
上載者:User

標籤:

<?php$mobile = "15810320826"; echo substr_replace($mobile,‘****‘,3 , 4); ?>

 

substr_replace

(PHP 4, PHP 5)

substr_replace — 替換字串的子串

說明mixed substr_replace ( mixed  $string , mixed  $replacement , mixed  $start [, mixed  $length ] )

substr_replace() 在字串 string 的副本中將由 start 和可選的 length 參數限定的子字串使用 replacement 進行替換。

參數

 

string

輸入字串。

An array of strings can be provided, in which case the replacements will occur on each string in turn. In this case, the replacement,start and length parameters may be provided either as scalar values to be applied to each input string in turn, or as arrays, in which case the corresponding array element will be used for each input string.

replacement

替換字串。

start

如果 start 為正數,替換將從 string 的 start 位置開始。

如果 start 為負數,替換將從 string 的倒數第 start 個位置開始。

length

如果設定了這個參數並且為正數,表示 string 中被替換的子字串的長度。如果設定為負數,它表示待替換的子字串結尾處距離string 末端的字元個數。如果沒有提供此參數,那麼它預設為 strlen( string ) (字串的長度)。當然,如果 length 為 0,那麼這個函數的功能為將 replacement 插入到 string 的 start 位置處。

傳回值

返回結果字串。如果 string 是個數組,那麼也將返回一個數組。

substr_replace()函數:將手機號中間4位隱藏為*號

聯繫我們

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