php get last 4 digits of string , fast 4 digits , first 5 chars

php get last 4 digits of string , fast 4 digits , first 5 chars


 php get last 4 digits of string , fast 4 digits , first 5 chars

Code Example: https://www.codegrepper.com/code-examples/php/php+get+last+4+digits+of+string

$newstring = substr($dynamicstring, -7);  //last 7 chars 
$result = substr("Hello How are you", 0, 5); //first 5 chars "Hello"



Displaying last 4-digit credit card

<?php
    $number =  "1122334455667788";
    $masked =  str_pad(substr($number, -4), strlen($number), '*', STR_PAD_LEFT);
    print $masked; //************7788
?>






HOME

Post a Comment

Previous Post Next Post