3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function explodeCustom($delimiter, $string) { $arr = array(); $deli_strlen = strlen($delimiter); while ($string) { $pos = strpos($string, $delimiter); if ($pos === false) { $arr[] = $string; $string = ''; } else { $arr[] = substr($string, 0, $pos); $string = substr($string, $pos + $deli_strlen); } } return $arr; } print_r(explodeCustom('aa', ',,aaa,,a,a,aa,')); print_r(explode('aa', ',,aaa,,a,a,aa,'));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => ,, [1] => a,,a,a, [2] => , ) Array ( [0] => ,, [1] => a,,a,a, [2] => , )