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. Linux的.run文件简单制作

    run程序安装包实质上是一个安装脚本加要安装的程序,如下图所示: |-----------------|| || 安装脚本 || ||-----------------|| || 程序 || ||-- ...

  2. 【Qt官方例程学习笔记】Address Book Example(代理模型)

    地址簿示例展示了如何使用代理模型在单个模型的数据上显示不同的视图. 本例提供了一个地址簿,允许按字母顺序将联系人分组为9组:ABC.DEF.GHI.…,VW,…XYZ.这是通过在同一个模型上使用多个视 ...

  3. 图片 响应式图像 Images Figures

    响应式图像 Bootstrap中的图像响应 .img-fluid <img class="img-fluid" src="http://lorempixel.com ...

  4. All Roads Lead to Rome(30)(MAP【int,string】,邻接表,DFS,模拟,SPFA)(PAT甲级)

    #include<bits/stdc++.h>using namespace std;map<string,int>city;map<int,string>rcit ...

  5. Codeforces Round #522 Div2C(思维)

    #include<bits/stdc++.h>using namespace std;int a[200007];int b[200007][7];int ans[200007];int ...

  6. 解读人:闫克强,Metabolic and gut microbial characterization of obesity-prone mice under high-fat diet(高脂饮食下易胖倾向小鼠的代谢和肠道微生物菌群特征分析)

    单位: 上海中医药大学 蚌埠医学院 上海交通大学附属第六人民医院 夏威夷大学癌症中心 第二军医大学 技术:非靶向代谢组学,16S rRNA测序技术 一. 概述: 本研究对小鼠进行高脂饮食,根据体重增长 ...

  7. QQ音乐MP3下载

    QQ音乐MP3下载 没错本次写的内容的对象是我们熟知的QQ Music. 本篇文章涉及内容包括:Python,爬虫,json解析,request 库的使用 缘起 前几天刷B站无意中又刷到了一首神曲,“ ...

  8. Spring Boot整合实战Spring Security JWT权限鉴权系统

    目前流行的前后端分离让Java程序员可以更加专注的做好后台业务逻辑的功能实现,提供如返回Json格式的数据接口就可以.像以前做项目的安全认证基于 session 的登录拦截,属于后端全栈式的开发的模式 ...

  9. CSS十一问——好奇心+刨根问底=CSSer

    最近有时间,想把酝酿的几篇博客都写出来,今天前端小学生带着10个问题,跟大家分享一下学习CSS的一些体会,我觉得想学好CSS,必须保持一颗好奇心和刨根问底的劲头,而不是复制粘贴,得过且过.本人能力有限 ...

  10. putty提示Network error:Software caused connection abort

    在 sshd host 的 /etc/ssh/sshd_config 设定: TCPKeepAlive yes,和将LoginGraceTime的值设为0,默认为2m,然后使用service sshd ...