Thursday 30 June 2016

Laravel help

View files [doc,csv,pdf,xml] in browser, How to show files in browser mode or file preview in browser


Use this :


1. Google doc viewer

 
https://docs.google.com/viewerng/viewer?url= FileNameOrFilePath
 
Ex: 
<a href="https://docs.google.com/viewerng/viewer?url=FileNameOrFilePath" target="_blank">
    Click here
 </a> 


Reference for Google Doc viewer:

https://github.com/jawish/jquery.gdocviewer

Or

Open as a iframe to display on own website :
<iframe src="http://docs.google.com/viewer?embedded=true&url=https://s3.amazonaws.com/pie-staging/uploads/development/file_attachment/document/31/ticketToShirdiNitinRajpurohit.pdf">
  <p>Your browser does not support iframes.</p>
</iframe>


2. Open office
 
https://view.officeapps.live.com/op/view.aspx?src= FileNameOrFilePath
 
 
Reference for Open office
  -  office-web-viewer 
  -  Office Url to view document
 
 
 

3.Data pipes for CSV file in browser Mode 

   http://datapipes.okfnlabs.org/csv/html/?url= FileNameOrFilePath
 
 
 Reference for data pipeline 
https://github.com/okfn/datapipes 
http://okfnlabs.org/blog/2013/12/05/view-csv-with-data-pipes.html



Wednesday 29 June 2016

PHP Array Type and Common PHP Array Function

PHP Array Types : 
An array is a special variable, which can hold more than one value at a time.
  • Indexed arrays - Arrays with a numeric index  => he index can be assigned automatically (index always starts at 0), like this:                                                                                         $cars = array("Volvo", "BMW", "Toyota");                                                                                                                                                                                  
  • Associative arrays - Arrays with named keys :Associative arrays are arrays that use named keys that you assign to them.                                                                                             $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");       foreach($age as $x => $x_value) {
        echo "Key=" . $x . ", Value=" . $x_value;
        echo "<br>";
    }                                                                                                                                                                                                                                                                                                                
  • Multidimensional arrays - Arrays containing one or more arrays
           A multidimensional array is an array containing one or more arrays.

          $cars = array(
           array("Volvo",22,18),
           array("BMW",15,13),
           array("Saab",5,2),
          array("Land Rover",17,15)
         );



PHP ARRAY FUNCTION :
1.array_key_exists("Volvo",$a)
2.array_flip()  Flips/Exchanges all keys with their associated values in an array
3.array_merge(array1,array2,array3...)
4.array_search("red",$a); return key 
5.in_array("Glenn", $people)
6.array_push($a,"blue","yellow");