zoukankan      html  css  js  c++  java
  • 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;

  • 相关阅读:
    数据库三级考试的随笔2.0
    数据库三级考试的随笔1.2
    数据库三级考试的随笔1.1
    数据库三级考试的随笔1.0
    陈贤文的第一次试水
    点分治总结
    Treap总结
    UML之二、建模元素(1)
    StarUML之九、starUML的一些特殊属性的说明
    UML之一、为什么需要UML?
  • 原文地址:https://www.cnblogs.com/jc535201285/p/6386678.html
Copyright © 2011-2022 走看看