3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "\tA\t B \tC \t D "; var_export( [ 'input' => $string, 'space, no flag' => preg_split('~ +~', $string), 'space, flag' => preg_split('~ +~', $string, -1, PREG_SPLIT_NO_EMPTY), 'tab, no flag' => preg_split('~\t+~', $string), 'tab, flag' => preg_split('~\t+~', $string, -1, PREG_SPLIT_NO_EMPTY), 'whitespace, no flag' => preg_split('~\s+~', $string), 'whitespace, flag' => preg_split('~\s+~', $string, -1, PREG_SPLIT_NO_EMPTY), 'tab&space, no flag' => preg_split('~[\t ]+~', $string), 'tab&space, flag' => preg_split('~[\t ]+~', $string, -1, PREG_SPLIT_NO_EMPTY), 'horizontal whitespace, no flag' => preg_split('~\h+~', $string), 'horizontal whitespace, flag' => preg_split('~\h+~', $string, -1, PREG_SPLIT_NO_EMPTY), ] );

preferences:
110.13 ms | 405 KiB | 5 Q