This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array( | |
array('levelname'=>'银','dis'=>7.5), | |
array('levelname'=>'金卡','dis'=>8.0), | |
array('levelname'=>'白金卡','dis'=>9.0) | |
); | |
function getMinAndMaxInArray($arr) { | |
if(empty($arr)) { | |
return array(10,10); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 1.number_format */ | |
$number = 1234.5678; | |
$nombre_format_francais = number_format($number, 2, ',', ' '); // 1234,57 | |
$english_format_number = number_format($number, 2, '.', ''); // 1234.57(我一般用这个) | |
/** 2.round */ | |
$number = 1234.5678; | |
echo round($number ,2); //1234.57 | |
/** 3.sprintf */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.tip_right{ | |
position: fixed; | |
top: 40%; | |
right: 0; | |
z-index: 1; | |
width: 25px; | |
-webkit-animation:right_tip 1.5s infinite; | |
} | |
@-webkit-keyframes right_tip | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、通过返回false来取消默认的行为并阻止事件起泡。 | |
jQuery 代码: | |
$("form").bind( | |
"submit", | |
function() { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $$ = function (func) { | |
if (document.addEventListener) { | |
window.addEventListener("load", func, false); | |
} | |
else if (document.attachEvent) { | |
window.attachEvent("onload", func); | |
} | |
} | |
$$(function () { | |
$("#bjimg ul li").height($("#bjimg ul li img").height()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js"></script> | |
<script type="text/javascript" src="http://malsup.github.com/jquery.form.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$('#uploadForm').ajaxForm({ | |
dataType: 'json', | |
success: processJson | |
}); | |
function processJson(data){ | |
alert(data.message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 字符串关键字过滤 | |
* @param $find 要查找的值 | |
* @param $replace 替换 find 中的值的值 | |
* @param $subject 被搜索的字符串 | |
* @return bool|mixed 返回替换后的字符串 | |
*/ | |
public function keyword_replace($find, $replace, $subject) | |
{ | |
if(is_array($find) && !empty($find)){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param $to 接收者邮箱 | |
* @param $subject 主题 | |
* @param $body 内容 | |
* @param $addattachment 附件 | |
* @return bool | |
*/ | |
public function send_email($to, $subject, $body, $addattachment) | |
{ | |
//获取email配置 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$style_obj = new PHPExcel_Style(); | |
$style_array = array( | |
'borders' => array( | |
'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), | |
'left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), | |
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), | |
'right' => array('style' => PHPExcel_Style_Border::BORDER_THIN) | |
), | |
'alignment' => array( | |
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
下面是总结的几个使用方法 | |
include 'PHPExcel.php'; | |
include 'PHPExcel/Writer/Excel2007.php'; | |
//或者include 'PHPExcel/Writer/Excel5.php'; 用于输出.xls的 | |
创建一个excel | |
$objPHPExcel = new PHPExcel(); | |
保存excel—2007格式 | |
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); | |
//或者$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel); 非2007格式 | |
$objWriter->save("xxx.xlsx"); |
NewerOlder