【PHP日期函数date格式化UNIX时间的方法_php技巧】教程文章相关的互联网学习教程文章

PHP获取文件大小并格式化

资料整理,具体出处未知~functionformatSize($size) {$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"); if ($size == 0) { return('n/a'); } else { return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); } } 版权声明:本文为博主原创文章,未经博主允许不得转载。以上就介绍了PHP获取文件大小并格式化,包括了方面的内容,希望对PHP教程有兴趣的朋友有所...

php格式化金额函数分享

/*** 格式化金额** @param int $money* @param int $len* @param string $sign* @return string*/ function format_money($money, $len=2, $sign=¥){$negative = $money > 0 ? : -;$int_money = intval(abs($money));$len = intval(abs($len));$decimal = ;//小数if ($len > 0) {$decimal = ..substr(sprintf(%01..$len.f, $money),-$len);}$tmp_money = strrev($int_money);$strlen = strlen($tmp_money);for ($i = 3; $i < $st...

JQuery里面金额的格式化

/** * 将数值四舍五入(保留2位小数)后格式化成金额形式 * * @param num 数值(Number或者String) * @return 金额格式的字符串,如1,234,567.45 * @type String */ function formatCurrency(num) { num = num.toString().replace(/\$|\,/g,); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cent...

[gist]在浏览器里免查看源代码格式化var_dump输出

Gist Link/** * 格式化var_dump输出... * 我勒个去。。早怎么没想到..就加了个pre啊,, */function var_dump_html($var){echo"";var_dump($var);echo""; }看完我想撞墙,为什么早没想到。。。以上就介绍了[gist]在浏览器里免查看源代码格式化var_dump输出,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

phpDOMDocument递归格式化缩进HTML文档

php DOMDocument 递归 格式化缩进HTML文档function format(\DOMNode $node, $treeIndex = 0) {//不格式化的标签if (in_array($node->nodeName, array("title", "p", "span")))return;if ($node->hasChildNodes()) {$treeIndex++;$tabStart = "\r\n" . str_repeat(" ", $treeIndex);$tabEnd = "\r\n" . str_repeat(" ", $treeIndex - 1);$i = 0;while ($childNode = $node->childNodes->item($i++)) {//去除空的text nodeif ($c...

工具|PHP格式化输出数组

function dump($vars, $label = '', $return = false) {if (ini_get('html_errors')) {$content = "\n";if ($label != '') {$content .= "{$label} :\n";}$content .= htmlspecialchars(print_r($vars, true));$content .= "\n\n";} else {$content = $label . " :\n" . print_r($vars, true);}if ($return) { return $content; }echo $content;return null; }参考:http://www.birdol.com/web/751.html以上就介绍了工具|PHP格式化...

php递归格式化数字类型php代码格式化工具sublimephp格式化php数组格式

/*** 数字转日期递归*@param list*@return list**/function day2str($key,$obj,$keys=array(create_time=>Y-m-d,s_time=>Y-m-d,e_time=>Y-m-d,usetime=>Y-m-d G:i:s)){if(is_array($obj)){//如果是 obj 或 数组 foreach ($obj as $k => $v) {$obj[$k] = day2str($k,$v,$keys);//递归 }return $obj;}else{if(!$type= $keys[$key] ){//去掉列表没有的项目return $obj; }if(is_numeric($key) ){//去掉数组类型return $obj;}if(!$obj...

yii2GridView日期格式化并实现日期可搜索案例androidgridview用法.netgridviewcgridview【图】

作者:白狼 出处:http://www.manks.top/article/yii2_gridview_dateformat_search本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。日期格式化,我们先来看看效果图这个我们分情况讨论1、如果你的数据库字段created_at存的时间格式是date或者datetime,那很简单,gridview中直接输出该字段created_at即可,如上图中右侧所示2、如果数据库存入的时间戳类...

PHP防注入函数格式化数据

代码如下://格式化数据(防止注入) function site_addslashes($string, $force = 0) { !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); if(!MAGIC_QUOTES_GPC || $force) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = daddslashes($val, $force); } } else { $string = addslashes($string); } } return $string; } ?> 以上就介绍了 PHP 防注入函数格式...

tf内存卡无法格式化PHP无限分类代码,支持数组格式化、直接输出菜单两种方式

代码如下:/** +------------------------------------------------ * 通用的树型类 +------------------------------------------------ * @author yangyunzhou@foxmail.com +------------------------------------------------ * @date 2010年11月23日10:09:31 +------------------------------------------------ */ class Tree { /** +------------------------------------------------ * 生成树型结构所需要的2维数组 +------...

js格式化GBK的页面输出JSON格式的php函数

代码如下:function tb_json_encode($value, $options = 0) { return json_encode(tb_json_convert_encoding($value, “GBK”, “UTF-8″)); } function tb_json_decode($str, $assoc = false, $depth = 512) { return tb_json_convert_encoding(json_decode($str, $assoc), “UTF-8″, “GBK”); } function tb_json_convert_encoding($m, $from, $to) { switch(gettype($m)) { case ‘integer: case ‘boolean: case ‘float: cas...

容量格式化函数

很简单的一段, 没啥好说的.. /** * 容量格式化 * * @param Int $filesize * @return Srting */function sizecount ($filesize){ if ($filesize >= 1073741824) $filesize = round($filesize / 1073741824 * 100) / 100 . GB; elseif ($filesize >= 1048576) $filesize = round($filesize / 1048576 * 100) / 100 . MB; elseif ($filesize >= 1024) $filesize = round($filesize / 1024...

格式化节点树的类,写得不好,没有算法,但可以用

将数据库取的分类数据格式化,如:新闻--体育新闻--娱乐新闻财经--外汇--金融class tree{ /**原始数据*/ public $original; /**id的键名*/ public $id; /**父id的键名*/ public $parentId; /**初始化时的id*/ protected $initId; /**节点的级别*/ protected $thisLevel = 0; /**最终树*/ protected $tree = array(); /** * 构造函数 +------------------------------------------ ...

PHP字符串格式化函数

函数列表:convert_cyr_string() crc32() hebrev() hebrevc() money_format() number_format() echo convert_cyr_string(The string, k,i); $checksum = crc32("This is the string.");printf("%u\n", $checksum); //hebrevc() 函数把希伯来文本从右至左的流转换为左至右的流。它也会把新行 (\n) 转换为 。//只有 224 至 251 之间的 ASCII 字符,以及标点符号受到影响。string hebre...

php无限分类树形数据格式化

简洁才是王道.... function genTree($items,$id=id,$pid=pid,$son = children){ $tree = array(); //格式化的树 $tmpMap = array(); //临时扁平数据 foreach ($items as $item) { $tmpMap[$item[$id]] = $item; } foreach ($items as $item) { if (isset($tmpMap[$item[$pid]])) { $tmpMap[$item[$pid]][$son][] = &$tmpMap[$item[$id]]; } else { $tree[] = &$tmpMap[$item[$id]]; } } unset($tmpMap); return $tre...