fork download
  1. <?php
  2.  
  3. $string = '<:header>HEADER</header><:main>MAIN<:item>ITEM</item></main>';
  4.  
  5. // passo 1
  6. $string = preg_replace( '/<.*?>/' , '|' , $string );
  7.  
  8. // passo 2
  9. $string = preg_replace('/\|+/', '|', $string);
  10.  
  11. // passo 3
  12. $string = array_filter( explode( '|' , $string ) );
  13.  
  14. print_r( $string );
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [1] => HEADER
    [2] => MAIN
    [3] => ITEM
)