streamlining URL replacement code
Posted: Sat Oct 01, 2011 9:37 pm
Well, I created a simple script to take anything written in the URL (?test=test&test2=test etc...) and POST it back to the page so it doesn't look ugly. It works, it's just very slow. I was just wondering if there's a way to streamline it so it'll be slightly faster. Any suggestions?
Here's the slow code
Again, any help at all would be great. Thanks!
Here's the slow code
Code: Select all
<?php
$url = strip_tags(str_replace("/", "", $_SERVER['REQUEST_URI']));
if($url != ""){
$url = str_replace("?", "", $url);
$vars = explode("&", $url);
$end = count($vars);
echo($lang_header_wait);
echo('<form action="http://'.$_SERVER['SERVER_NAME'].'/" method="post" id="redir">');
for($i=0;$i<$end;$i++){
$var = explode("=", $vars[$i]);
echo('<input type="hidden" name="'.$var[0].'" value="'.$var[1].'">');
}
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
exit();
}