1.创建一个数组:
$array1 = array("name"=>"xiaoming", "age"=>20);
$array2 = array("xiaoming", 20);
2.添加一个有键值对的数组元素
array_push($array2, "男", "大学");
$array1 ['sex'] = "男";
3.时间-字符串
(1)时间->字符串
$time = strtotime("2010-09-08 07:06:05"); $stringtime = date("Y-m-d H:i:s",$time); // 2010-09-08 07:06:05 (比如s是1,前边补零:01,其他都是如此)
$stringCurTime = date("Y-m-d H:i:s"); // 当前时间
(2)字符串->时间
$time = strtotime($stringtime);
4.for循环
for ($x=0; $x<10; $x++) {
echo $x."<br>";
}
5.xml
$xml=simplexml_load_file($路径或者网页请求);
$item = $xml->Items->Item;//获取某个节点
6.判断远程图片或者文件或url是否存在
http://www.phpddt.com/php/php-image-exist.html
7.科学计数法->字符串(如:4.98711554071E+12->4987115540713)
if (stripos($num, 'e') !== false) {// stripos找位置,不区分大小写
$result = "";
while($num > 0) {
$v = $num - floor($num / 10) * 10;
$num - floor($num / 10);
$result = $v.$result;
}
return $result;
}
8.C#写文件
FileStream fs = new FileStream("a.html", FileMode.Create);
StreamWriter sw = new StreamWriter(fs, Encoding.Default);
sw.Write(str);
sw.Close();
fs.Close();