Skip to content

Instantly share code, notes, and snippets.

@chucktrukk
Created June 2, 2011 21:43
Show Gist options
  • Save chucktrukk/1005395 to your computer and use it in GitHub Desktop.
Save chucktrukk/1005395 to your computer and use it in GitHub Desktop.
remove double slashes from modx output
<?php
$output = $this->modx->documentOutput;
$pattern = '/<a[^>]*>/';
preg_match_all($pattern, $output, $matches);
$matches = array_pop($matches);
$replace = array();
foreach($matches as $key => $match) {
$matches[$key] = $match;
$replace[$key] = preg_replace('~/+~', '/', $match);
}
$output = str_replace($matches, $replace, $output);
$this->modx->documentOutput = $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment