Skip to content

Instantly share code, notes, and snippets.

View avinash2's full-sized avatar

Avinash K. avinash2

View GitHub Profile
<?php
$blog = array(
'title' => 'My Blog',
'author' => 'Avinash',
'pages' => array('about','services','folio','contact'),
);
?>
@avinash2
avinash2 / array-output.php
Created February 25, 2011 08:21
Outputting values stored in an array
<?php
$blog = array(
'title' => 'My Blog',
'author' => 'Avinash',
'pages' => array('about','services','folio','contact'),
);
// Using the 'foreach' construct to output key => value pairs stored in an array
<?php
$blog = array(
'title' => 'My Blog',
'author' => 'Avinash',
'pages' => array('about','services','folio','contact'),
);
// Outputting values stored in nested arrays
<?php
$file = "img/15.jpeg";
$data = exif_read_data($file); // Returns a Multidimensional array containing image META information
print_r($data);
?>
<?php
$file = "img/15.jpeg";
$data = exif_read_data($file);
// Let's create a new array that will store the required image properties and values
$img = array();
$img["name"] = $data['FileName'];
$img["make"] = $data['Make'];
$img["model"] = $data['Model'];
@avinash2
avinash2 / guess-game.py
Created February 25, 2011 15:04
A simple console guessing game
#!usr/bin/env python
secret = 101
guess = input('Guess the correct number: ')
print 'You have entered: ', guess
if guess < secret :
print 'Your guess is lower than the expected number. Try again?'
@avinash2
avinash2 / multidarray-all.php
Created March 5, 2011 18:33
Outputting all the values stored in a multidimensional array
<?php
$file = "img/15.jpeg";
$data = exif_read_data($file);
echo "<ul>\n";
foreach ($data as $key => $value)
{
// Checks if $value is an array
if (is_array($value)) {
echo "<li><strong>{$key}</strong>:</li>\n";
@avinash2
avinash2 / gist:868628
Created March 14, 2011 01:20
Basic HTML markup
<!DOCTYPE html>
<html>
<head>
<title>My Simple Gallery</title>
<link rel="stylesheet" href="css/gallery.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
@avinash2
avinash2 / gist:868631
Created March 14, 2011 01:25
A basic PHP Gallery function
<?php
function genGallery($path)
{
$files = scandir("$path");
$pages = array_chunk($files, 12);
$pn = (int) $_GET['page'];
foreach ($pages[$pn] as $file) {
@avinash2
avinash2 / gist:868637
Created March 14, 2011 01:30
Gallery is now running!
<!DOCTYPE html>
<html>
<head>
<title>My Simple Gallery</title>
<link rel="stylesheet" href="css/gallery.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<?php include('gallery.php'); ?>
</head>
<body>