Ds \ Vector::join()函數是PHP中的一個內置函數,用於使用提供的分隔符作為參數將vector的所有元素作為字符串連接。
用法:
string public Ds\Vector::join( $glue )
參數:此函數接受單個參數$glue,該參數用於保存分隔符。它是一個可選參數。
返回值:此函數以字符串形式返回向量的值。
以下示例程序旨在說明PHP中的Ds \ Vector::join()函數:
程序1:
<?php
// Create new vector
$vector = new \Ds\Vector([1, 2, 3, 4, 5]);
// Display the vector element
print_r($vector);
echo("\nVector elements after joining\n");
print_r($vector->join());
?>輸出:
Ds\Vector Object
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
Vector elements after joining
12345
程序2:
<?php
// Create new vector
$vector = new \Ds\Vector(["geeks", "for", "geeks"]);
// Display the vector element
print_r($vector);
echo("\nVector elements after joining\n");
print_r($vector->join("|"));
?>輸出:
Ds\Vector Object
(
[0] => geeks
[1] => for
[2] => geeks
)
Vector elements after joining
geeks|for|geeks
參考: http://php.net/manual/en/ds-vector.join.php
相關用法
- PHP join()用法及代碼示例
- p5.js join()用法及代碼示例
- PHP Ds\Set join()用法及代碼示例
- Node.js join()用法及代碼示例
- PHP Ds\Deque join()用法及代碼示例
- PHP Ds\Sequence join()用法及代碼示例
- Node.js path.join()用法及代碼示例
- d3.js d3.lab()用法及代碼示例
- p5.js str()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
- d3.js d3.set.add()用法及代碼示例
- CSS var()用法及代碼示例
注:本文由純淨天空篩選整理自barykrg大神的英文原創作品 PHP | Ds\Vector join() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
