Friday 24 June 2016

How to add external link in target and class

<head>
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type='text/javascript'>
$( document ).ready(function() {

  $('a').filter(function() {
  return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');

  $('a').filter(function() {
  return this.hostname && this.hostname !== location.hostname;
}).addClass("external");

});
    </script>
</head>

Wednesday 1 June 2016

How to remove extra Spaces, Tabs and Line feeds in php?

<?php

$string ="<b>About PHp</b>

Originally created by Rasmus      Lerdorf in 1994, the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group. While PHP originally stood for Personal Home Page,


it now stands for PHP: Hypertext Preprocessor, which is a recursive backronym.";

$new_string= preg_replace("/\s+/", " ", $string);

echo $new_string;

?>

Output:-  About PHp Originally created by Rasmus Lerdorf in 1994, the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext Preprocessor, which is a recursive backronym.