[英]How to replace last 15 digits of a string with x?
假設我有一個要顯示在用戶設置頁面上的字符串。 這是特定用戶的HWID,但我想隱藏像與字符串中的最后15個字符x
的例子。 這個怎么做 ? 大概preg_replace()
..請讓我知道。
示例字符串: aaaec315bbfb9184fd9d7c8e165b297d
但示例顯示為aaaec315bbfb9184f**************
我相信它只能包含字母數字字符,因為它是HWID。
$string = substr($string,0,-15)."xxxxxxxxxxxxxxx";
雖然@hellocde的示例做到了這一點,但我只是使用了本機的substr_replace函數,因為這正是它的目的。
substr_replace($string, 'xxxxxxxxxxxxxx', -15);
會產生:
aaaec315bbfb9184fdxxxxxxxxxxxxxx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.