PHP自定义函数&数组

<?php
//生成随机数 和 时间函数
//echo rand();
//echo "<br>";
//echo rand(0,10);
//echo time();//时间戳
//2017-02-10 08:46:12
date_default_timezone_set("Asia/Shanghai");

//echo date("Y-m-d h:i:s");//默认转换当前时间
//echo date("Y-m-d h:i:s",'1386688343');
//echo strtotime("2013-12-10 11:12:23");
//字符串的处理
//$str = 'Hello World!!!';
//echo strlen($str);
//$str1='Abc';
//$str2='abc';
//echo strcmp($str1,$str2);
//echo strcasecmp($str1,$str2);
//echo strtoupper($str2);
//echo strtolower($str1);

//$str = "a|B|c|d";

//$str1 = explode("|",$str);
//echo implode("&",$str1);

//echo substr($str,1,3);
//echo str_replace("|","&",$str);
//echo substr_replace($str,"%",1,1);
//$str = "hello3 world4 ashdf223sdfa2323sd45454";
//preg_match("/\d/",$str,$str2);
//preg_match_all("/\d/",$str,$str3);
//var_dump($str3);
//$str4 = preg_replace("/\d/", "数字", $str);
//var_dump($str4);
//$str5 = preg_split("/\d/",$str);
//var_dump($str5);
//function hansm($v)
//{
//    $v++;
//    return $v;
//}
//$temp = hansm(5);
//echo $temp;
//function test($a, $b = 3)
//{
//    return $a + $b;
//}
//
//echo test(2,4);
//function test2()
//{
//    $arr = func_get_args();
//    return $arr;
//}
//var_dump(test2(2,3));
//$arr = array();
//var_dump($arr);

$arr = array('x', 'y', 34);

$arr2 = array(
    'x' => 'a',
    'y' => 'b',
    'z' => 'c',
    9 => 35
);
//$arr_merge=array_merge($arr,$arr2);
//var_dump($arr_merge);
//echo $arr2[2];
//var_dump($arr2);
//array_push($arr2,'xxx');
//var_dump($arr2);
//var_dump(in_array('v',$arr2));
//$arr_reverse = array_reverse($arr2);
//var_dump($arr_reverse);
//unset($arr2);
//$ar2 = null;
//var_dump($arr2);
//for($i=0;$i<count($arr2);$i++)
//{
//
//}
foreach ($arr2 as $k)
{
    var_dump($v);
}
foreach ($arr2 as $k=>$v){
    var_dump($arr2[$k]);
}
//echo $v;

posted @ 2017-02-10 15:47  周全264  阅读(239)  评论(1编辑  收藏  举报