HH\Lib\Str\join

Meta Engineer?

This is available as Str\join in the www repository.

Returns a string formed by joining the elements of the Traversable with the given $glue string

namespace HH\Lib\Str;

function join(
  Traversable<arraykey> $pieces,
  string $glue,
): string;

Previously known as implode in PHP.

Guide

Parameters

Returns

  • string

Examples

$strings= vec["a", "b", "c", "d"];

$joined_string_1 = Str\join($strings, ",");
echo "First string: $joined_string_1 \n";

$joined_string_2 = Str\join($strings, "-");
echo "Second string: $joined_string_2";