ini bakal sering dipakai jadi saya tulis
<?php
$testarr = array("a" => 1, "b" => 2, "c" => 3, "d" => 4);
echo "ap";
print_r($testarr);
echo "<hr>";
$testarr_keys = array_keys($testarr);
$testarr_values = array_values($testarr);
for ($i = 0; $i <count($testarr) ; $i++) {
//testarr[$testarr_keys[$i]] = $testarr_values[$i] * 2;
// echo "testarr_keys $testarr_keys[$i]<br>";
echo "testarr_values $testarr_values[$i]<br>";
}
?>
Minggu, 14 Juli 2013
Rabu, 27 Februari 2013
code php get array from excel file xlsx
<table border=1>
<?php
//<pre>
//error_reporting(E_ALL);
set_time_limit(0);
ini_set("memory_limit","256M");
include 'rand.php';
include 'PHPExcel.inc.php';
include "db.php";
mysql_connect($site["dbhost"], $site["dblogin"], $site["dbpass"]);
mysql_select_db($site["dbname"]);
date_default_timezone_set('Asia/Jakarta');
$inputFileName = $_GET[inputFileName];
$mulai = $_GET[mulai];
echo "inputFileName $inputFileName <br>";
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'include_lib/Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$csheet = $objPHPExcel->getSheetCount();
$loadedSheetNames = $objPHPExcel->getSheetNames();
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
$hal++;
$ahal[] = $hal;
if($hal==1){
}
// echo "hal $hal <br>";
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$cbaris = count($sheetData);
$cbaris1 = $cbaris+1;
for($baris=1;$baris<$cbaris1;$baris++){
$koloma= $sheetData[$baris][A];
$kolomb= $sheetData[$baris][B];
$kolomc= $sheetData[$baris][C];
$kolomd= $sheetData[$baris][D];
$kolome= $sheetData[$baris][E];
$kolomf= $sheetData[$baris][F];
$kolomg= $sheetData[$baris][G];
$kolomh= $sheetData[$baris][H];
$kolomk= $sheetData[$baris][K];
$koloml= $sheetData[$baris][L];
$kolomj= $sheetData[$baris][J];
echo "$koloma - $kolomb - $kolomc - $kolomd - $kolome - $kolomf - $kolomg - $kolomh - $kolomi - $kolomj <br>";
}
}
echo "OK";
?>
Langganan:
Postingan (Atom)