Ds \ Sequence::unshift()函數是PHP中的內置函數,用於將值添加到序列的字體中。
用法:
void abstract public Ds\Sequence::unshift( $values )
參數:此函數接受單個參數$values,其中包含要添加到序列字體中的值。
返回值:此函數不返回任何值。
以下示例程序旨在說明PHP中的Ds \ Sequence::unshift()函數:
程序1:
<?php
// Create new sequence
$seq = new \Ds\Vector([12, 15, 18, 20]);
// Use unshift() function to
// the sequence element
$seq->unshift("Geeks");
$seq->unshift("1", 1);
print_r($seq);
?>輸出:
Ds\Vector Object
(
[0] => 1
[1] => 1
[2] => Geeks
[3] => 12
[4] => 15
[5] => 18
[6] => 20
)
程序2:
<?php
// Create new sequence
$seq = new \Ds\Vector(["Geeks", "for", "Geeks"]);
// Use unshift() function to
// the sequence element
$seq->unshift(1);
$seq->unshift("G", 10);
var_dump($seq);
?>輸出:
object(Ds\Vector)#1 (6) {
[0]=>
string(1) "G"
[1]=>
int(10)
[2]=>
int(1)
[3]=>
string(5) "Geeks"
[4]=>
string(3) "for"
[5]=>
string(5) "Geeks"
}
參考: http://php.net/manual/en/ds-sequence.unshift.php
相關用法
- PHP Ds\Deque unshift()用法及代碼示例
- PHP Ds\Vector unshift()用法及代碼示例
- Node.js unshift()用法及代碼示例
- PHP SplDoublyLinkedList unshift()用法及代碼示例
- PHP dir()用法及代碼示例
- p5.js nf()用法及代碼示例
- p5.js nfp()用法及代碼示例
- PHP pi( )用法及代碼示例
- CSS rgb()用法及代碼示例
- PHP pow( )用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js nfc()用法及代碼示例
注:本文由純淨天空篩選整理自Mahadev99大神的英文原創作品 PHP | Ds\Sequence unshift() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
