fork(2) download
  1. <?php
  2. function remove_non_tag_space($text){
  3. $len = strlen($text);
  4. $out = "";
  5. $in_tag=false;
  6. for($i=0;$i<$len; $i++){
  7. $c = $text[$i];
  8. if($c=='<')
  9. $in_tag=true;
  10. elseif($c=='>')
  11. $in_tag=false;
  12.  
  13. $out .= $c==" "? ($in_tag? $c: ""): $c;
  14. }
  15. return $out;
  16. }
  17.  
  18. echo remove_non_tag_space(' foo fo o o o oo <img src="foo.png ">')
  19. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
foofoooooo<img src="foo.png ">