You can simply hide and show the last digit numbers with jQuery php and css.

Here is the script to hide and show the last 4 digit of the string

<?php
echo "Hello World";
$no = "+97152432XXXX";
$hide = substr($no, -4);
$shono = substr($no, 0, -4);
echo $hide;
?>
<script type="text/javascript" 
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<link rel="stylesheet" type="text/css" 
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<div id="number" data-last="<?php echo $hide ?>">
<?php echo $shono; ?><span>show</span></div>
<script>
$('#number').click(function() {
 $(this).find('span').text( $(this).data('last') );
});
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *