php取随机数 explode劫取字符串 时间定义随机数
php取随机数
<?php
function randomkeys($length)
{
$pattern='1234567890';
for($i=0;$i<$length;$i++)
{
$key .= $pattern{mt_rand(0,10)}; //生成php随机数
}
return $key;
}
echo randomkeys(9);
?>
explode劫取字符串
$source = "hello1,hello2,hello3,hello4,hello5";//按逗号分离字符串
$hello = explode(',',$source);
for($index=0;$index<count($hello);$index++)
{
$hello1=$hello[$index];
echo $hello[$index];echo "</br>";
echo $hello1;
echo "</br>";
}
时间定义随机数
<?php
date('YmdHis').rand(1000,9999)
?>
更改文件名
date()//得到当前时间,格式自己定!
如;假设当前上传的文件叫'1.jpg',你的文件域名叫file,上传的文件在根目录下面;
$date=date('Ymdhis');//得到当前时间,如;20070705163148
$fileName=$_FIFLES['file']['name'];//得到上传文件的名字
$name=explode('.',$fileName);//将文件名以'.'分割得到后缀名,得到一个数组
$newPath=$date.'.'.$name[1];//得到一个新的文件为'20070705163148.jpg',即新的路径
$oldPath=$_FILES['file']['tmp_name'];//临时文件夹,即以前的路径
rename($oldPath,$newPath);就可以重命名了!
php取随机数 explode劫取字符串 时间定义随机数的更多相关文章
- 九、SAP中使用定义时间及使用sy-uzeit取当前时间
一.sy-uzeit为取当前时间函数,类型t为时间类型,代码如下: 二.输出结果如下:
- SQL server 存储过程 C#调用Windows CMD命令并返回输出结果 Mysql删除重复数据保留最小的id C# 取字符串中间文本 取字符串左边 取字符串右边 C# JSON格式数据高级用法
create proc insertLog@Title nvarchar(50),@Contents nvarchar(max),@UserId int,@CreateTime datetimeasi ...
- JS 字符串 时间 数字函数操作 事件
字符串 操作 var s="abcdefg" s.tolowerCase() 转小写 s.toupperCase() 转大写 s.substring(2,5) 索引下 ...
- ***PHP implode() 函数,将数组合并为字符串;explode() 函数,把字符串打散为数组
实例 把数组元素组合为字符串: <?php $arr = array('Hello','World!','I','love','Shanghai!'); echo implode(" ...
- C++ string类取字符串的左右子串(以特定子串为分界限)
// Example3.cpp : 定义控制台应用程序的入口点. //以特定单词为分界,求取字符串的左右子串 #include "StdAfx.h" #include <st ...
- wordpress取文章时间
wordpress的时间处理, 取文章的本地时间用get_the_time('c'),其中c可以用“D, d M Y H:i:s"等替代. 取文章的UTC时间用get_post_time(' ...
- 取字符串拼音首字母(js)
//取字符串拼音首字母 function makePy(str) { if (typeof(str) != "string") throw new Error(-1, " ...
- 字符串时间与Unix时间戳相互转换
字符串时间与Unix时间戳相互转换 /** * @Author: wangkun * @Date : 2016/1/21 13:43 * @Description : 字符串时间转换为Unix时间戳 ...
- DOS 如何取当前时间做为文件名?
如果要取得以日期为文件名的文件,假设在命令行下键入date返回形式为:当前日期: 2005-06-02 星期四echo > %date:~0,4%%date:~5,2%%date:~8,2%~表 ...
随机推荐
- CF 602B Approximating a Constant Range
(●'◡'●) #include<iostream> #include<cstdio> #include<cmath> #include<algorithm& ...
- java ee开发报错
七月 26, 2015 9:57:52 下午 org.apache.coyote.AbstractProtocol destroy信息: Destroying ProtocolHandler [&qu ...
- 5、Spring+Struts2+MyBatis+分页(mybatis无代理)增删改查
1.创建如下项目结构 2.在src下的com.entity包下创建Dept.java package com.entity; /** * 部门表 * @author Holly老师 * */ publ ...
- 朱丽叶—Cuda+OSG
#include <cuda_runtime.h> #include <osg/Image> ; typedef struct cuComplex { float r; flo ...
- PHP7新功能及语法变化总结
1.标量类型声明有两种模式: 强制 (默认) 和 严格模式. 现在可以使用下列类型参数(无论用强制模式还是严格模式): 字符串(string), 整数 (int), 浮点数 (float), 以及布尔 ...
- hdu2063 匈牙利算法 二分最大匹配模版题
过山车 Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Java class na ...
- html5+css3学习笔记-prefixfree前缀补全插件
虽然现代浏览器支持CSS3,但是一些过往的版本或是目前有些CSS3属性的应用还是离不开前缀的.一些牛逼且执着于web技术且乐于分享的仁兄(Lea Verou)就搞了个名叫prefixfree.js的插 ...
- 关于UIFont和计算字符串的高度和宽度
转自:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.创建方法:+ fontWithName:size:- fontWithSize:2.创建系统字体:+ sy ...
- 12C CLONE PDB and config service_listener
Clone PDB PtestDEV to Ptestuat in testuat 1) Clone PtestDEV to Ptestuat C:\Windows\system32> ...
- Hash算法冲突解决方法分析
采用开放定址法处理散列表的冲突时,其平均查找长度? 高于链接法处理冲突 低于二分查找 开放定址法:一旦发生冲突,就去寻找下一个空的散列地址,只要散列地址够大,空的地址总会找到 链地址法: 一旦发生冲 ...