str::split($string, $separator = ',', $length = 1)

Better alternative for explode() It takes care of removing empty values and it has a built-in way to skip values which are too short.

  • $string (string)
    The string to split
  • $separator (string)
    The string to split by
  • $length (int)
    The min length of values.
  • return (array)
    An array of found values

Example

<?php
$string = 'Kirby, CMS, file-based';
$split = str::split($string);
a::show($split);

Result:

Array
(
  [0] => Kirby
  [1] => CMS
  [2] => file-based
)