fork(1) download
  1. <?php
  2. header("Content-Type: text/plain; charset=utf-8");
  3. ?>
  4. <?php
  5.  
  6. $text = <<<TEXT
  7.  <head>
  8.  <b><!-- <i> это комментарий -->
  9. <title>Форма заказа товара</title>
  10. <meta http-equiv="Content-type" content="text/html" charset="windows-1251">
  11. <meta name="keywords" content="">
  12. <meta name="description" content="">
  13. <div>
  14.   <empty>
  15.   </empty>
  16.   <p>
  17.   This is yet another text
  18.   <br/>
  19.   that wasn't
  20.   <b>
  21.   compliant
  22.   </b>
  23.   too...
  24.   <br/>
  25.   </p>
  26.   <div class="noClass">
  27.   this one is better but we don't care anyway
  28.   </div>
  29. TEXT;
  30. echo $text;
  31. $pattern = "/(<([\w]+)[^>]*>)/";
  32. preg_match_all($pattern, $text, $new, PREG_SET_ORDER);
  33. foreach ($new as $k => $v) {
  34. print_r($new[$k][2]);
  35. echo "\n";
  36. }
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
 
 <head>
 <b><!-- <i> это комментарий -->
<title>Форма заказа товара</title>
<meta http-equiv="Content-type" content="text/html" charset="windows-1251">
<meta name="keywords" content="">
<meta name="description" content="">
<div>
     <empty>
     </empty>
     <p>
       This is yet another text
       <br/>
       that wasn't
       <b>
         compliant
       </b>
       too...
       <br/>
     </p>
     <div class="noClass">
       this one is better but we don't care anyway
     </div>head
b
i
title
meta
meta
meta
div
empty
p
br
b
br
div