note 47282 added to function.str-replace

From: Date: Wed, 10 Nov 2004 04:01:26 +0000
Subject: note 47282 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-80330@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 (http://www.goomzee.com) ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47282 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47282&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47282&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47282&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47282&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47282&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47282&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47282&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80330) next »