將h1取代成h2並且置入新的內容
<?php $new = "ABC"; $str = "<h1 class='test'>123</h1>"; $str = preg_replace("/<h1(.*?)>(.*?)<\/h1>/", "<h2>{$new}</h2>", $str); echo $str; ?>
酷米 © All Rights Reserved.