Friendly file size string

 public static function bytesToSize($bytes)
{
if ($bytes < 1024) {
return '< 1k';
} else if ($bytes < 1048576) { // 1024 * 1024
return round($bytes/1024, 2) .'K';
} else if ($bytes < 1073741824) { // 1024 * 1024 * 1024
return round($bytes/1048576, 2) .'M';
} else {
return round($bytes/1073741824, 2) .'G';
}
12 }

Duration of the song

 public static function secToStr($sec)
{
$hours = floor($sec / 3600);
$minutes = floor(($sec / 60) % 60);
$seconds = $sec % 60; if ($hours > 0) {
return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
} else {
return sprintf("%d:%02d", $minutes, $seconds);
}
}

PHP snippets的更多相关文章

  1. [OpenCV] Install OpenCV 3.4 with DNN

    目标定位 一.开始全面支持 Tensorflow OpenCV3.4 新功能 当前最新进展OpenCV 3.4 dev:https://github.com/opencv/opencv/tree/ma ...

  2. Code Snippets 代码片段

    Code Snippets 代码片段       1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...

  3. Xcode开发中 Code Snippets Library 的相关用法

    当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...

  4. 25+ Useful Selenium Web driver Code Snippets For GUI Testing Automation

    本文总结了使用Selenium Web driver 做页面自动化测试的一些 tips, tricks, snippets. 1. Chrome Driver 如何安装 extensions 两种方式 ...

  5. Random Javascript code snippets

    MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...

  6. VS 添加Snippets

    Code Snippet 下载文件: propfull.7z copy到C:\Users\哲\Documents\Visual Studio 2013\Code Snippets\Visual C#\ ...

  7. VS代码段扩展Snippet Designer is a Visual Studio plug in which allows you to create and search for snippets inside the IDE

    Snippet Designer is a Visual Studio plug in which allows you to create and search for snippets insid ...

  8. Xcode开发技巧之Code Snippets Library

    http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...

  9. visual studio snippets风格

    snippet挺好用,但是不是我喜欢的那种风格,比如if是这样的 if () { XX } 而我比较习惯这种: if () { XX } 可以这么做: 工具(Tools)——代码段管理器(Code S ...

  10. Xcode Snippets

    在Double Encore,我们写的代码都是干净,可重用的——不过,有时候并不能完全做到.如在使用pragma mark的时候.下面就是一个示例:   #pragma mark - UIViewCo ...

随机推荐

  1. PHP获取原生POST数据

    To get the Raw Post Data: <?php $postdata = file_get_contents("php://input"); ?> 参考官 ...

  2. PureUI(扩展版本)

    喜欢一个UI(pure,官网)不怎么更新(可能官方认为不需要更新).我自己做了扩展和修正,整个库下载地址:http://files.cnblogs.com/files/RainbowInTheSky/ ...

  3. Unity中限制轴向移动范围Mathf.Clamp

    Mathf.Clamp   在游戏中,为了限制玩家的某一轴向的移动不超过一定的范围,可以用Mathf.Clamp来解决 Mathf.Clamp(float value,float min,float ...

  4. C# 中介者模式

    中介者模式 中介者模式,定义了一个中介对象来封装一系列对象之间的交互关系.中介者使各个对象之间不需要显式地相互引用,从而使耦合性降低,而且可以独立地改变它们之间的交互行为. 结构: 中介者模式设计两个 ...

  5. Asp.Net 遍历 循环 显示所有COOKIS,SESSION,Applocation

    在C#中循环显示SESSIOn: Response.Write("<br>Session的所有值:<br>"); foreach (string obj i ...

  6. python接口自动化(三十六)-封装与调用--流程类接口关联续集(详解)

    简介 上一篇已经给大家都介绍过了流程类接口关联,但是由于博客的登录机制改变,所以没有办法给小伙伴们实战演练一下,那么这篇就按照上一篇计划的用jenkins来给小伙伴们演示一下流程类接口的封装和调用,其 ...

  7. rowid去重(转)

    实际应用场景:数据去重--当多条记录主键相同或者多条记录完全一致时,只需要留下一条记录 delete from bal_acctbook_info where rowid not in (select ...

  8. php文件上传(视频图片或者其他)

    html页面 <html> <head> <meta charset="utf-8"> <title></title> ...

  9. POJ1043 What's In A Name?

    题目来源:http://poj.org/problem?id=1043 题目大意: 一个犯罪团伙有n个成员,每人有一个唯一的字符串作为id,每人还有一个唯一的字符串作为name.该团伙有一个hideo ...

  10. Eclipse设置控制台字体

    打开 Window - preferences-- general - appearance - colors and fonts --debug - console font 进行设置.