fork download
  1. <?php
  2.  
  3. $s = 'HOME
  4. this
  5. could
  6. have
  7. many
  8. lines
  9. HOME
  10. this
  11. one
  12. also
  13. HOME
  14. same';
  15. print_r( preg_split('~^(?=HOME$)~m', $s, -1, PREG_SPLIT_NO_EMPTY) );
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
Array
(
    [0] => HOME
    this
    could
    have
    many
    lines

    [1] => HOME
    this
    one
    also

    [2] => HOME
    same
)