good morning boys and girls…can someone point me to the right direction, please.
i want to replace my php-echo-output
JUNE 29, 2009–JULY 5, 2009
with just plain text: last week
<?php
ob_start();
wp_get_archives('type=weekly&limit=1');
$wklyarchives = ob_get_contents();
ob_end_clean();
$wklyarchives = preg_replace('%–[a-zA-Z0-9, ]*</a>%s', 'last week</a>', $wklyarchives);
echo $wklyarchives;
?>
this preg_replace replaces just the 2nd part, so my output is now JUNE 29, 2009last week
this preg makes me crazy…
You are only matching the dash and the part after it, so that’s exactly what is getting replaced. If you add the same character class before the dash, like
it should work (depending on what
$wklyarchives
contains even before the ‘JUNE 29’ part; you might have to make sure you don’t mach too much).Okay, tried this with WordPress, worked fine:
Remember, do not use output buffering with wp_get_archives. Use echo=0:
Good luck.