note 47281 added to function.str-repeat

From: Date: Wed, 10 Nov 2004 03:59:42 +0000
Subject: note 47281 added to function.str-repeat
Groups: php.notes 
Request: Send a blank email to php-notes+get-80329@lists.php.net to get a copy of this message
For printing invoices with only the last 4 digits of a credit card showing, we used both str_repeat and str_replace functions as follows: <?php echo substr_replace($var, str_repeat("*", strlen($var)-4), 0, -4); ?> $var being the raw credit card number and '*' being the desired placeholder for the other digits. Enjoy! Mike Sparr - Goomzee Web Services ---- Manual Page -- http://www.php.net/manual/en/function.str-repeat.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47281 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47281&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47281&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47281&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47281&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47281&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47281&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47281&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80329) next »