PHP and MySQL – storing quotes

The best way to store quotes htmlentities($campaignsubject, ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML401); And to decode it back use html_entity_decode($rowsCampaigns[‘content’],ENT_QUOTES|ENT_SUBSTITUTE|ENT_HTML401);

PHP determine masked string

Here is a preg_match expression for finding if a string contains a certain set of repeated characters, say like the masking characters in a stored credit number or say a hidden phone number if(preg_match(“/x{5,12}/”,”THE STRING”))  // if there are 12 consecutive x in the string, starting from position 6  

Legends in Morris Chart

With help from this article https://github.com/morrisjs/morris.js/issues/346 This is about adding Legends to Morris charts. Though Morris chart shows legend on hovering on the graphs, but I wanted to show a legend permanently on one corner of the chart area. Below are the codes. It is mostly plug and play code The div in which the… Continue reading Legends in Morris Chart

PHP substr_replace

Want to mask part of a string – 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],”xxxxxxxxxxxx”,6,12); //this will replace 12 characters starting from 6th position substr_replace(API_PASS,”xxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,6,28); //this will replace 28 characters starting from 6th position of the string