亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php筆記之:php函數(shù)range() round()和list()的使用說明

 更新時間:2013年04月26日 16:44:02   作者:  
本篇文章介紹了,php函數(shù)range() round()和list()的使用說明。需要的朋友參考下

一>>

range()函數(shù)快速創(chuàng)建數(shù)組的簡單方法,使用low到high范圍的整數(shù)值填充數(shù)組,函數(shù)將返回一個包含次范圍內(nèi)所有整數(shù)的數(shù)組.形式如下

array range(int low,int high[,int step])

典型用法如下

例子:建立1-6的6個數(shù)字的數(shù)組(骰子)

$die = range(0,6);

建立0-30所有雙數(shù)的數(shù)組

$even  = (0,20,2);//步長為2

這個函數(shù)不僅僅可以用作數(shù)字,還可以用作字母.

$words = range('A','Z');

將建立包含A到Z的的所有字母的數(shù)組.此處可以用于生成驗證碼函數(shù).

二>>

round()函數(shù)

這個函數(shù)是怕我記混淆了.這個函數(shù)和上面的哪個range()是天壤之別.

這個函數(shù)的作用是

取浮點數(shù)的精度

float round(float var[,int preisin})

典型用法

例: $pi = 3.141592653;

round($pi,4);

echo $pi;

將輸出 3.1415

三>>

list()函數(shù)

list()函數(shù)可以在一次操作中從一個數(shù)組內(nèi)提取多個值.同時為變量賦值.形式如下

void list(mixed)

典型用法

復(fù)制代碼 代碼如下:

<?php

$info = array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";

// Listing some of them
list($drink, , $power) = $info;
echo "$drink has $power.\n";

// Or let's skip to only the third one
list( , , $power) = $info;
echo "I need $power!\n";

?>

上例摘自PHP手冊
可以用list()配合正則來切割字符串存入變量表
典型用法
 
list($name,$occupation,$color) = exolode("|",$line); 

相關(guān)文章

最新評論