【PHP Ds Sequence first()函数介绍和用法】Ds \ Sequence :: first()function是PHP中的内置函数, 用于返回序列中的第一个元素。
语法如下:
mixed abstract public Ds\Sequence::first ( void )
参数:该函数不接受任何参数。
返回值:此函数返回序列中的第一个元素。
下面的程序说明了Ds \ Sequence :: first()PHP中的功能:
范例1:
<
?php// Create new sequence
$seq =new \Ds\Vector([10, 20, 13, 25]);
// Display the first element from the sequence
var_dump( $seq ->
first());
// Create new sequence
$seq =new \Ds\Vector([ 'G' , 'e' , 'e' , 'k' , 's' ]);
// Display the first element from the sequence
var_dump( $seq ->
first());
?>
输出如下:
int(10)
string(1) "G"
范例2:
<
?php// Create new sequence
$seq =new \Ds\Vector([21, 23, 'p' , 'x' ]);
// Display the first element
// from the sequence
var_dump( $seq ->
first());
// Function to push an element
$seq ->
insert(0, "G" );
// Display the first element
// from the sequence
var_dump( $seq ->
first());
?>
输出如下:
int(21)
string(1) "G"
参考: http://php.net/manual/en/ds-sequence.first.php
推荐阅读
- jQuery event.isImmediatePropagationStopped()方法用法示例
- 在操作系统中分页-实现算法解析
- LOOK磁盘调度算法解析和代码实现详解
- PHP Ds Vector clear()函数用法介绍
- PHP Ds Sequence find()函数用法介绍
- 分组密码和流密码之间的区别
- JavaScript 数组迭代方法介绍用法实例
- 2个VueJS实战开发实例
- VueJS响应接口用法详解