to replacements $REPLACE = array( 'search' => array("u_id", "url", "page", "offset", "mid", "bid", "sub", "home"), 'replace' => array("u" , "url", "page", "offset", "m" , "b" , "s" , "h") ); if ((EXT_IS_ACTIVE("admins")) && (eregi("admin=", $test))) { // Replace &admin= with "/aid/" $REPLACE['search'][] = "admin"; $REPLACE['replace'][] = "aid"; } // END - if // Replace all array elements through foreach ($REPLACE['search'] as $k => $v) { if (eregi("$v=", $test)) { // Replace &u_id= with /u/ $test = preg_replace("/&".$v."=/i", "/".$REPLACE['replace'][$k]."/", $test); } // END - if } // END - foreach // Repair missed &what=??? entries while (preg_match("/&what=(.*)\/(.*)\/(.*)/i", $test)) { $test = preg_replace("/&what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $test); } // END - while // Return rewritten code return $test; } // ?>