At the moment I use this code:
Code: Select all
// ==============================
// Link All The Pages
// ==============================
$match_count = preg_match_all("/linkid\-([0-9]*)\-/si", $body_content, $matches);
$matches[1] = array_unique($matches[1]);
for ($i = 0; $i < $match_count; $i++) {
$linkid = "";
$body_content_linkid = "";
$linkid = $matches[1][$i];
$linkid_info = mysql_fetch_array(mysql_query("select slug from {$tbl_name}pages where id='$linkid'"));
###############################
# Mod_Rewrite
if ($mod_rewrite == "y") {
$body_content_linkid = $websiteurl."/".$linkid_info[slug];
} else {
$body_content_linkid = "index.php?page=".$linkid_info[slug];
}
###############################
$body_content = str_replace("http://linkid-{$linkid}-", $body_content_linkid, $body_content);
$body_content = str_replace("linkid-{$linkid}-", $body_content_linkid, $body_content);
}Is there a better way to do it so that it loads faster? Maybe run one query and put all the results into an array and then use preg_replace or erg_replace (I'm not sure which one) to replace the fields from the array.
What do you think? Any ideas?