Skip to content

Instantly share code, notes, and snippets.

View kayalshri's full-sized avatar

Giri Raj kayalshri

View GitHub Profile
@kayalshri
kayalshri / reversertext
Created February 4, 2014 11:58
To Display reverse Text
<?php
$reverse = array();
# Split based on space (words)
$words = explode(' ', 'samsung galaxy 8260');
# Get the words count
$toProcess = count($words);
@kayalshri
kayalshri / terrinary
Created February 4, 2014 11:59
Terrinary operator usage
<?php
$test = 'Works!';
echo $test ?: 'Not working :(';
?>
@kayalshri
kayalshri / Wordcount
Created February 4, 2014 12:02
To Get the words count from string
<?php
$text = "The UPA government braces itself for the last session of the 15th Lok Sabha, hoping to persuade the Opposition to cooperate with it in clearing an ambitious legislative agenda.Six anti-corruption laws and the controversial Bills on Telangana, women’s reservation and communal violence are on the agenda, apart from two votes on account.The government’s parliamentary managers are working overtime to soften the Opposition, but the BJP has thus far made it clear that it will not pass anything unless there is order in the House.";
$wordCount = array_count_values(str_word_count($text, 1));
asort ($wordCount);
echo "<pre>" . var_export($wordCount, true) . "</pre>";
>?
<?php
$description = '<div class="field field-name-field-image field-type-image field-label-hidden"><div class="field-items"><div class="field-item even"><a href="/pattern/popover-tip-billionaire"><img src="http://patterntap.com/sites/default/files/styles/pattern-thumb/public/newpatterns/506f0e6a77a47.png" /></a></div></div></div><div class="field field-name-field-source field-type-link-field field-label-hidden"><div class="field-items"><div class="field-item even"><a href="http://www.billionaire.com/" target="_blank" class="source">http://www.billionaire.com/</a></div></div></div>';
$dom = DOMDocument::loadHTML($description) or die("HTML parse error");
$nodelist = $dom->getElementsByTagName('img');
$nb = $nodelist->length;
for($pos=0; $pos<$nb; $pos++) {
$node = $nodelist->item($pos);
<?php
print date("Y-m-d", strtotime("+0 months")).'<Br /><Br />';
print date("Y-m-d", strtotime("+1 months"));
?>
<?php
class intro {
public $fname;
public $lname;
public $age;
public $qualification;
public $job;
public $interests;
public $skill;
CREATE TABLE `login` (
`name` VARCHAR(255),
`id` INT(8) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
);
CREATE TABLE `employee` (
`eid` INT(8)
);
dbsetup.ini
==========
[dev]
DB_SERVER = "servername:port"
DB_NAME = "dbname"
DB_USER = "username"
DB_PASSWORD = "xxxxxxxxxxx"
[prod]
DB_SERVER = "servername:port"
@kayalshri
kayalshri / php cache
Created February 4, 2014 12:48
PHP SIMPLE CACHE EXAMPLE
<?php
define("PHP_CACHE_DIR", "./");
$cd = date("m/d/Y");
$cachefile = PHP_CACHE_DIR."PHP_CACHE_".md5($cd).".CHE";
if (file_exists($cachefile)) {
include $cachefile;
echo "Loading from cachefile <br>";
}else{
APACHE Installation
===================
sudo yum install httpd
sudo service httpd start
Verify the Apache version
httpd –v
curl –I localhost
rpm –qa | grep –w httpd-[0-9]