Let's say I've got a string which I want to display on my user's settings page. It's the HWID of the specific user but I want to hide like the last 15 characters from the string with x
for example. How to do this ? Probably preg_replace()
.. please let me know.
Example string: aaaec315bbfb9184fd9d7c8e165b297d
but it will display like aaaec315bbfb9184f**************
for exmaple
I believe it can only contain an alphanumeric characters since it's a HWID.
$string = substr($string,0,-15)."xxxxxxxxxxxxxxx";
While @hellocde's example does do this, I would just use the native substr_replace function instead as this is what it's intended for.
substr_replace($string, 'xxxxxxxxxxxxxx', -15);
Which will produce:
aaaec315bbfb9184fdxxxxxxxxxxxxxx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.