PHP自定义函数&数组

高洛峰
Lepaskan: 2023-03-05 20:32:01
asal
1016 orang telah melayarinya

<?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",&#39;1386688343&#39;);
//echo strtotime("2013-12-10 11:12:23");
//字符串的处理
//$str = &#39;Hello World!!!&#39;;
//echo strlen($str);
//$str1=&#39;Abc&#39;;
//$str2=&#39;abc&#39;;
//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(&#39;x&#39;, &#39;y&#39;, 34);

$arr2 = array(
    &#39;x&#39; => &#39;a&#39;,
    &#39;y&#39; => &#39;b&#39;,
    &#39;z&#39; => &#39;c&#39;,
    9 => 35
);
//$arr_merge=array_merge($arr,$arr2);
//var_dump($arr_merge);
//echo $arr2[2];
//var_dump($arr2);
//array_push($arr2,&#39;xxx&#39;);
//var_dump($arr2);
//var_dump(in_array(&#39;v&#39;,$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;
Salin selepas log masuk

更多PHP自定义函数&数组相关文章请关注PHP中文网!

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan