Wednesday, April 27, 2016

Custom download to excel using php


 <?php
 $content="<table><tr><td style='color:red;background-color:green;'>created by bikash</td></tr></table>";

$downloadFileName = 'test_report_'.time().'.xls';
 $filename = SITE_PATH_SPDATA."xml_data/reports/$downloadFileName";
 header("Cache-Control: no-store, no-cache, must-revalidate");
 header("Cache-Control: post-check=0, pre-check=0", false);
 header("Pragma: no-cache");
 header("Content-Type: application/vnd.ms-excel");
 header("Content-Length: strlen($achDowloadContent)");
 header("Content-Disposition:; filename=$downloadFileName");
 echo $contents;

?>

Wednesday, March 2, 2016

String value swap suing two variable without use third variable in php

<?php
 $a="value stored in a";
 $b="value stored in b";
 $a= $a.$b;  

    $b =substr($a,0,strlen($a)-strlen($b)) ;
    $a = substr($a,strlen($b));
    echo strlen($b);

    echo ("a = ".$a)
    echo ("b = ".$b);
    exit;
?>