This should work using substr
:
function ccMasking($number, $maskingCharacter="X") {
return substr($number, 0, 4) . str_repeat($maskingCharacter, strlen($number) - 8) . substr($number, -4);
}
More Related Contents:
- how to make css work with php? [closed]
- We need a script to create a backup of all the files, database and email using third party Cpanel details in PHP
- How do I catch a PHP fatal (`E_ERROR`) error?
- HTTP authentication logout via PHP
- How can I loop through a MySQL result set more than once using the mysql_* functions?
- PHP json_decode() returns NULL with valid JSON?
- instantiate a class from a variable in PHP?
- Connect PHP to MSSQL via PDO ODBC
- php: recreate and display an image from binary data
- jQuery – Call ajax every 10 seconds
- How do I give each registered user their own url using PHP?
- MySQL “NOT IN” query 3 tables
- PHP end tag “?>” [duplicate]
- is PHP str_word_count() multibyte safe?
- PHP URL Encoding / Decoding
- How to set a class attribute to a Symfony2 form input
- Dynamically create PHP object based on string
- How to build unlimited level of menu through PHP and mysql
- Call PHP from virtual/custom “web server”
- Laravel 5 Session Lifetime
- How to identify web-crawler?
- How do I access PHP REST API PUT data on the server side?
- PHP – Delete XML Element
- Convert all node’s attributes into child nodes
- Permission denied: /var/www/abc/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable?
- PHP Include for HTML?
- selected value get from db into dropdown select box option using php mysql error
- Add a fee to an order programmatically in Woocommerce 3
- Is it possible to execute PHP with extension file.php.jpg?
- Conditionally add associative element to array