php中sprintf定义和用法
php删除数组元素几种方法
array_slice() 第一个参数是要切割的数组,第二个参数是起始位置,第三个参数是长度。
就是 切割 $arr这个数组,从第0个元素往后数3个。
中文汉字正则表达式javascript/php
php中session用法详细介绍
phpexcel读写xls文件实现程序
<?php
include_once('PHPExcel.php');
//read excel file;
$PHPExcel = new PHPExcel();
$PHPReader = new PHPExcel_Reader_Excel5();
$PHPExcel = $PHPReader->load('/home/yuanjianjun/taobao_cat.xls');
$currentSheet = $PHPExcel->getSheet(0);
$allColumn = $currentSheet->getHighestColumn();
$allRow = $currentSheet->getHighestRow();
for($currentRow = 1; $currentRow<=$allRow; $currentRow++){
for($currentColumn='A'; $currentColumn<=$allColumn; $currentColumn++){
$address = $currentColumn.$currentRow;
echo $currentSheet->getCell($address)->getValue()."t";
}
echo "n";
}
php中session_unset与session_destroy的用法与区别
PHP中array_slice函数用法介绍
array_slice() 函数在数组中根据条件取出一段值,并返回。
php实现文件下载功能的流程分析
php中数组遍历循环实现程序
PHP中Exception异常处理类的使用详解
php中向数组中插入一元素程序代码
<?php
/**
* 逆序二维数组插入一元素
*
* @author WadeYu
* @date 2012-05-30
*/
$aSorted = array(
array(1, 100),
array(2, 90),
array(3, 80),
array(4, 70),
array(5, 60),
array(6, 50),
array(7, 40),
array(8, 40),
array(9, 40),
array(10, 20),
);
$aInsert = array(11, 40);
$maxCmpIdx = 0;
$cnt = 0;
$maxCnt = 10;
foreach ($aSorted as $idx => $arr){
if ($arr[0] == $aInsert[0]){
$maxCmpIdx = $idx;
}
$cnt++;
}
if ( !$maxCmpIdx){
$maxCmpIdx = $cnt++;
}
$aSorted[$maxCmpIdx] = $aInsert;
for ($i = $maxCmpIdx; $i > 0; $i--){
if ($aSorted[$i][1] > $aSorted[$i-1][1]){
$aTmp = $aSorted[$i-1];
$aSorted[$i-1] = $aSorted[$i];
$aSorted[$i] = $aTmp;
continue ;
}
break;
}
for ($i = $cnt; $i > $maxCnt; $i--){
unset($aSorted[$i-1]);
}
print_r($aSorted);