本文主要向大家介绍了PHP语言之PHP中文函数连载(二),通过具体的内容向大家展示,希望对大家学习php语言有所帮助。

函数count()

描述:

计算一变量中元素的个数

int count (mixed var);

Returns the number of elements in var , which is typically an array (since anything else will have one element).

Returns 0 if the variable is not set.

Returns 1 if the variable is not an array.

函数current()

描述:

传回数组指针目前所指的元素

mixed current (array array);

Each array variable has an internal pointer that points to one of its elements. In addition, all of the elements in the array are linked by a bidirectional linked list for traversing purposes. The internal pointer points to the first element that was inserted to the array until you run one of the functions that modify that pointer on that array.

The current() function simply returns the array element that's currently being pointed by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list, current() returns false.

函数each()

描述:

返回数组中下一对key/value的值

array each (array array);

Returns the current key/value pair from the array array and advances the array cursor. This pair is returned in a four-element array, with the keys 0 , 1 , key , and value . Elements 0 and key each contain the key name of the array element, and 1 and value contain the data.

Example 1. each() examples

$foo = array( "bob", "fred", "jussi", "jouni" ); $bar = each( $foo );

$bar now contains the following key/value pairs:

0 => 0

1 => 'bob'

key => 0

value => 'bob'

$foo = array( "Robert" => "Bob", "Seppo" => "Sepi" ); $bar = each( $foo );

$bar now contains the following key/value pairs:

0 => 'Robert'

1 => 'Bob'

key => 'Robert'

value => 'Bob'

Example 2. Traversing $HTTP_POST_VARS with each()

echo "Values submitted via POST method:

";

while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {

echo "$key => $val

";

}

函数end()

描述:

将数组中的指针移到最后一个

end (array array);

end() advances array 's internal pointer to the last element.

函数key()

描述:

从一数组中取出key

mixed key (array array);

key() returns the index element of the current array position.

函数ksort()

描述:

以key来排列一数组

Example 1. ksort() example

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");

ksort($fruits);

for(reset($fruits);

$key = key($fruits);

next($fruits)) { echo "fruits[$key] = ".$fruits[$key]." "; }

This example would display: fruits[a] = orange fruits[b] = banana fruits[c] = apple fruits[d] = lemon

函数list()

描述:

用类似数组的方式去指定一整串变量的值

Example 1. list() example

while (list($id, $name, $salary) = mysql_fetch_row($result)) {

print("  "." "." "."  ");

}

?>

Employee name

Salary

$name    $salary

函数next()

描述:

将数组的指向指到下一组数据

函数pos()

描述:

传回数组的当前的数据

函数prev()

描述:

传回数组的前一条的数据

函数reset()

描述:

数组的指针指到第一条

函数rsort ()

描述:

以倒序方式排列一个数组

Example 1. rsort() example

$fruits = array("lemon","orange","banana","apple");

rsort($fruits);

for(reset($fruits); ($key,$value) = each($fruits); ) {

echo "fruits[$key] = ".$value." ";

}

This example would display: fruits[0] = orange fruits[1] = lemon fruits[2] = banana fruits[3] = apple The fruits have been sorted in reverse alphabetical order.

函数sizeof()

描述:

取得一个数组的大小和元素的数目

函数sort()

描述:

排序数组

Example 1. sort() example

$fruits = array("lemon","orange","banana","apple");

sort($fruits);

for(reset($fruits);

$key = key($fruits);

next($fruits)) {

echo "fruits[$key] = ".$fruits[$key]." ";

}

This example would display: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange The fruits have been sorted in alphabetical order.

函数uasort()

描述:

以自定义的方式排列一个数组且序列不变。

函数uksort()

描述:

以自定义的方式以key排列

This function will sort the keys of an array using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. Example 1. uksort()

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标编程语言PHP频道!

php 函数 中文,PHP语言之PHP中文函数连载(二)相关推荐

  1. c语言接受mysql中文,C语言连接MySQL中文问题

    C语言连接MySQL中文问题 在学习<Linux程序设计>第8章MySQL数据库8.3节: 使用C语言访问MySQL访问数据库时尝试把SQL数据换成了中文,但是在运行示例程序时终端输出却乱 ...

  2. C语言中比较大小的函数模板,C语言中实现模板函数小结 : 不敢流泪

    --by boluor 2009/5/20 如果要写个函数支持多种数据类型,首先想到的就是C++的模板了,但是有时候只能用C语言,比如在linux内核开发中,为了减少代码量,或者是某面试官的要求- 考 ...

  3. c++中的fork函数_linux c语言 fork() 和 exec 函数的简介和用法

    linux c语言 fork() 和 exec 函数的简介和用法 假如我们在编写1个c程序时想调用1个shell脚本或者执行1段 bash shell命令, 应该如何实现呢? 其实在<stdli ...

  4. c语言第八章函数程序设计,C语言程序设计-第八章 函数.ppt

    C语言程序设计-第八章 函数 函数分类(从用户使用角度 ) 1.标准函数(库函数,由系统提供 ): 例如:printf 函数 .sqrt函数. 2.用户自定义函数: 例如,上面程序中的max 函数. ...

  5. 51单片机c语言编程函数,单片机C语言教程:C51函数

    其实一直出现在例子中的 main()也算是一个函数,只不过它比较特殊,编译时以它做为程序的开始段.有了函数C 语言就有了模块化的优点,一般功能较多的程序,会在编写程序时把每项单独的功能分成数个子程序模 ...

  6. c语言 字符串拷贝函数作用,C语言不使用strcpy函数如何实现字符串复制功能

    Ⅰ )字符串复制函数 字符串复制是字符串操作中比较常用的操作之一.C语言库函数中提供的字符串复制函数是:strcpy函数.该函数的功能为:把源字符数组中的字符串复制到目的字符数组中,字符串结束标志&q ...

  7. c语言以数组作为函数参数,C语言将数组作为函数参数

    一个函数的形参是普通的局部变量.当发生函数调用时,程序创建这些形参,然后用对应的实参来初始化这些形参.形参的作用域就是函数块.函数内可以改变形参的值,而不会影响调用上下文中实参的值. 如果需要将一个数 ...

  8. c语言字符串数组函数参数,C语言/C++ 数组作为函数参数

    前几天帮别人解决数组拼接问题(类似字符串拼接)时想到这个专题.因为她的代码太糟糕. 我们知道C.C++中的数组是没有拷贝(复制)运算的,除非编译器支持.因为C语言发明的初衷是替换汇编语言,要知道你用不 ...

  9. c语言中总是从main函数开始,C语言总是从main函数开始执行吗

    //-------------------------------------------------------- 本文目录结构 |-提出问题 |-解决问题 |-推荐文章 |-作业 //------ ...

最新文章

  1. Windows Home Server 2011 RC 安装体验
  2. 腾讯面试题:创建索引时,你会怎么考虑呢?(看完你就能和面试官谈人生了)
  3. vs2015 企业版、专业版如何破解(秘钥)
  4. python飞机大战源代码-python飞机大战源码和素材
  5. 数据库经典书籍--数据库系统概念
  6. 攻防世界-Misc-something_in_image(秒懂!!)
  7. C语言结构体里的成员数组和指针
  8. 使用Lucene的新FreeTextSuggester查找长尾建议
  9. 秋高气爽FreeEIM
  10. docker server 容器连接sql_Docker 容器的网络连接
  11. VC++ 在两个程序中 传递字符串等常量值的方法:使用了 WM_COPYDATA 消息的
  12. Python根据正则表达式找到相应的字符串然后进行替换
  13. 理工科硕士自学ICEM网格划分的思考和感悟
  14. 【LRC动态歌词制作—B站音频】“清新的小女孩-July Tun”为例
  15. 福利大放送:空间统计插值大数据PPT
  16. HTML源码大放送1
  17. Intel处理器家族及命名规则
  18. 学计算机平面设计的基础知识,新手学习平面设计2要点_计算机平面设计
  19. WeChat 微信防撤回的方法 plus
  20. 论文大致思路(不断更新)

热门文章

  1. python 压缩字符串_python zlib - 压缩字符串的大小与香农熵
  2. c语言中休眠的作用,使用C语言让Windows睡眠/休眠
  3. 什么叫matlab仿真,【图片】求助帖:哪位matlab大神能告诉我这个仿真这能得出什么结论呢_matlab吧_百度贴吧...
  4. mysql innodb 报错_mysql报错1286 Unknown storage engine 'InnoDB'
  5. 怎么获取服务器接口文档,服务器接口获取数据
  6. Modbus​协议​深入​讲解_NI
  7. JavaScript获取日期方法
  8. 2.9 iframe
  9. android studio shell 命令行自动打包(mac 平台)
  10. ECSHOP隐藏帮助中心文章页的评论功能方法