Fix for Fix for Now with div.header replacement!

  1. $contents = file_get_contents('./index.html');
  2.  
  3. // Remove DOS carriage returns:
  4. $contents = str_replace(chr(13), '', $contents);
  5.  
  6. // Inital QP
  7. $qp = qp('<div>' . $contents . '</div>');
  8.  
  9. // Loop through all elements that have either an
  10. // href attr or a src attr.
  11. foreach ($qp->find('[href],[src]') as $link) {
  12.   // Figure out which attr we are going to replace
  13.   $src_attr = $link->attr('src');
  14.   $attr_name = empty($src_attr) ? 'href' : 'src';
  15.  
  16.   // Do the replacement
  17.   $link->attr($attr_name, custom_url_fix($path, $link->attr($attr_name)));
  18. }
  19.  
  20. // Replace <br> with newlines
  21. $qp->branch()->top()->find('br')->after("\n")->remove();
  22.  
  23. // Replace headers
  24. foreach ($qp->branch()->top()->find('div.header') as $header) {
  25.   $title = $header->text();
  26.   $parent = $header->branch()->parent();
  27.   $header->branch()->replaceWith('<h3></h3>');
  28.   $parent->find('h3')->text($title);
  29. }
  30.  
  31. // Get the parent wrapper context.
  32. print $qp->top()->xml();

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.