Skip to content

Instantly share code, notes, and snippets.

@abedsujan
abedsujan / source and demo
Created February 18, 2012 01:49
Text to Image Using PHP and img4me
http://www.linein.org/blog/
@abedsujan
abedsujan / call jquery slide show method
Created February 18, 2012 01:37
Read All Images from a folder And display slide show.
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script src="jquery.innerfade.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$('#image_rotate').innerfade({
speed: 'slow',
timeout: 2000,
type: 'sequence',
containerheight: '220px'
});
@abedsujan
abedsujan / PHP Form Validation
Created February 12, 2012 20:39
PHP::Basic form validation using PHP (username, number, string, email)
<?php
/**
* This function can be used to check the sanity of variables
*
* @access private
*
* @param string $type The type of variable can be bool, float, numeric, string, array, or object
* @param string $string The variable name you would like to check
* @param string $length The maximum length of the variable
*
@abedsujan
abedsujan / gist:1810735
Created February 12, 2012 20:31
MySQL::Select the Nth Highest Record in a Database Table
Step: MySQL provides LIMIT clause so we just have to leverage it to rewrite the query as follows
SELECT *
FROM table_name
ORDER BY column_name DESC
LIMIT n - 1, 1
Step :Query to get the nth highest record
SELECT *
FROM (
@abedsujan
abedsujan / gist:1810695
Created February 12, 2012 20:18
.htaccess Files for the Rest of Us
http://net.tutsplus.com/articles/news/htaccess-files-for-the-rest-of-us/
@abedsujan
abedsujan / gist:1798944
Created February 11, 2012 11:49
PHP: Week Days.
// set current date
$date = '04/30/2009';
// parse about any English textual datetime description into a Unix timestamp
$ts = strtotime($date);
// find the year (ISO-8601 year number) and the current week
$year = date('o', $ts);
$week = date('W', $ts);
// print week for the current date
for($i = 1; $i <= 7; $i++) {
// timestamp from ISO week date format
@abedsujan
abedsujan / flatten
Created February 6, 2012 01:15
Flatten and Inflate n-dimensional arrays in php
private function flatten($array, $base = "", $div_char = "/")
{
$ret = array();
if(is_array($array))
{
foreach($array as $k => $v)
{
if(is_array($v))
{
$tmp_array = flatten($v, $base.$k.$div_char, $div_char);
@abedsujan
abedsujan / gist:1748769
Created February 6, 2012 01:13
Multidimensional Array Implode
function r_implode( $glue, $pieces )
{
foreach( $pieces as $r_pieces )
{
if( is_array( $r_pieces ) )
{
$retVal[] = r_implode( $glue, $r_pieces );
}
else
{
@abedsujan
abedsujan / gist:1748740
Created February 6, 2012 01:03
Convert Object class to Array
function objectToArray( $object )
{
if( !is_object( $object ) && !is_array( $object ) )
{
return $object;
}
if( is_object( $object ) )
{
$object = get_object_vars( $object );
}