{"id":685,"date":"2019-03-25T02:59:49","date_gmt":"2019-03-25T02:59:49","guid":{"rendered":"https:\/\/www.kolkataonweb.com\/code-bank\/?p=685"},"modified":"2019-03-12T11:05:39","modified_gmt":"2019-03-12T11:05:39","slug":"php-substr_replace","status":"publish","type":"post","link":"https:\/\/www.kolkataonweb.com\/code-bank\/php\/php-substr_replace\/","title":{"rendered":"PHP substr_replace"},"content":{"rendered":"<p>Want to mask part of a string &#8211; say a API key or the first 12 digits of a credit card?<\/p>\n<p>Here is a PHP function for doing the job easily<\/p>\n<pre class='wp-code-highlight prettyprint'>substr_replace(API_USER],\"xxxxxxxxxxxx\",6,12); \/\/this will replace 12 characters starting from 6th position\r\n\r\nsubstr_replace(API_PASS,\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",6,28); \/\/this will replace 28 characters starting from 6th position of the string<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Want to mask part of a string &#8211; say a API key or the first 12 digits of a credit card? Here is a PHP function for doing the job easily substr_replace(API_USER],&#8221;xxxxxxxxxxxx&#8221;,6,12); \/\/this will replace 12 characters starting from 6th position substr_replace(API_PASS,&#8221;xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#8221;,6,28); \/\/this will replace 28 characters starting from 6th position of the string &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[175,174],"class_list":["post-685","post","type-post","status-publish","format-standard","hentry","category-php","tag-masking-digits-of-cc","tag-masking-password","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/comments?post=685"}],"version-history":[{"count":1,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/685\/revisions"}],"predecessor-version":[{"id":686,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/685\/revisions\/686"}],"wp:attachment":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/media?parent=685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/categories?post=685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/tags?post=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}