Change language

PHP Ds / Vector join () function

|
Syntax:
string public DsVector::join ($glue)
Parameters: This function takes one parameter, $glue, which is used to store the delimiter. This is an optional parameter.Return Value:This function returns the value of a Vector as a string.The following programs illustrate the Ds / Vector::join function()in PHP:Program 1:  
// Create a new vector $vector = new DsVector ( [1, 2, 3, 4, 5]);  
// Show vector element print_r ( $vector ); echo ( " Vector elements after joining " ); print_r ( $vector -> join());  
?>
Output:
DsVector Object ([0] = > 1 [1] = > 2 [2] = > 3 [3] = > 4 [4] = > 5) Vector elements after joining 12345
Program 2:  
// Create a new vector $vector = new DsVector ([ " engineer " , " for " , "engineer" ]);  
// Show vector element print_r ( $vector ); echo ( " Vector elements after joining " ); print_r ( $vector -> join ( " | " ) );  
?>
Output:
DsVector Object ([0] = > engineer [1] = > for [2] = > engineer) Vector elements after joining engineer | for | engineer
Link: http://php.net/manual/en/ds-vector.join.php