Wednesday, 16 December 2015

Avoid mouse scroll wheel zoom on embedded map

Common problem facing while embedding map in out web page is, instead going down, getting stuck at the map area when we scroll down using mouse. To avoid it, better way is

   <html>
  <div class='map_container'>
<iframe width='600' height='450' frameborder='0' src='http://foo.com'></iframe>
  </div>
   </html>

  <style>
.map_container{
pointer-events: none;
}
   </style>

Opacity only to Background image of div

We can do more neat things using css and css3. Opacity is one of the great property of css. Setting opacity level to html elements directly is a simple thing. But we can also set the opacity only to Background image of html elements. We can implement background image's opacity property using two methods.

Method1: Opacity to Background image of div using css's pseudo elements.

This one is most preferred method used to make opacity on background image. Css3 has psuedo elements to support and make easy of complicated effects.
Eventually, one nice demo on CodePen:

Eventually, one nice demo on CodePen:


See the Pen Opacity to background image2 by Suresh (@phpguidesuresh) on CodePen.

Method2: Opacity to Background image of div using positioning an image.

This is a one of the most featured method for background image's opacity. Here img tag seems to be used as background image. Relative positioning of image is important.

Eventually, one nice demo on CodePen:


Tuesday, 15 December 2015

Remove last character from String in PHP

There are three common ways to remove last character from String.

They are
  •  substr and mb_substr
  •  substr_replace 
  •  rtrim

Remove last character from String in PHP using "substr and mb_substr"

$str = "Remove last character..";
echo substr($str, 0, -1);
echo mb_substr($str, 0, -1);

Remove last character from String in PHP using "substr_replace"

$str = "Remove last character..";
echo substr_replace($str ,"",-1);

Remove last character from String in PHP using "rtrim"

$str = "Remove last character..";
echo rtrim($str, ".");

Example

$str = "Remove last character..";

echo "substr: ".substr($str, 0, -1);
echo "<br/>";
echo "mb_substr: ".mb_substr($str, 0, -1);
echo "<br/>";
echo "substr_replace: ".substr_replace($str ,"",-1);
echo "<br/>";
 echo "rtrim: ".rtrim($str, ".");