Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Str\split() in Facebook's www repository.

Returns a vec containing the string split on the given delimiter

namespace HH\Lib\Str;

function split(
  string $string,
  string $delimiter,
  ?int $limit = NULL,
): vec<string>;

The vec will not contain the delimiter itself.

If the limit is provided, the vec will only contain that many elements, where the last element is the remainder of the string.

To split the string into equally-sized chunks, see Str\chunk().

Previously known as explode in PHP.


  • string $string
  • string $delimiter
  • ?int $limit = NULL


  • vec<string>