Import xls data to MYSQL

mysql_connect(“localhost”,”root”,””) or die(“cannot connect”); mysql_select_db(“db_name”) or die(“cannot find database”); $dataSheetFile=”sample_csv.csv”; $counter=0; if (($handle = fopen($dataSheetFile, […]

array_slice

$input = array(“red”, “green”, “blue”, “yellow”); $splice1=array_splice($input, 1, count($input), “orange”); $splice2=array_splice($input, 1, count($input)-1, “mango”); print_r($splice1); […]

Create image from text using PHP

function createImageFromText($text,$fontSize=12,$fontColor=”#FFF”,$imageSize=array(300,50),$fontFamily=”arial.ttf”,$rotationAngle=0, $xCoordinate=20, $yCordinate=120){ header(“Content-type: image/png”); //Picture Format header(“Expires: Mon, 01 Jul 2003 00:00:00 GMT”); […]

Permutation Functions

$array = array(‘rajan’, ‘kumar’, ‘maharjan’);function permutation($arr, $temp_string, &$collect) {    if ($temp_string != “”)         $collect []= $temp_string;    for ($i=0; $i<sizeof($arr);$i++) {        $arrcopy = $arr;        $elem = array_splice($arrcopy, $i, 1);        if (sizeof($arrcopy) > 0) {            permutation($arrcopy, $temp_string .” ” . $elem[0], $collect);        } else {            $collect []= $temp_string. ” ” . $elem[0];        }       }   } $collect = array();permutation($array, “”, $collect);for($i=0;$i<count($collect);$i++){    for($j=0;$j<=$i;$j++){        $spaceCountI = explode(” “,$collect[$i]);        $spaceCountJ = explode(” “,$collect[$j]);               if($spaceCountJ>=$spaceCountI){            $temp = $collect[$j];            $collect[$j] = $collect[$i];            $collect[$i] = $temp;            }        }    }echo “<pre>”;print_r(array_reverse($collect));echo “</pre>”;