A Function to Build Query Strings : Query String : Development PHP Source Code


PHP Source Code » Development » Query String »

 

A Function to Build Query Strings



<html>
<head>
<title>A function to build query strings</title>
</head>
<body>
<?php
function qlink$q ){
    GLOBAL $QUERY_STRING;
    if ! $q 
       return $QUERY_STRING;
    $ret = "";
    foreach$q as $key => $val ) {
        if strlen$ret ) ) 
           $ret .= "&";
        $ret .= urlencode$key "=" . urlencode$val );
    }
    return $ret;
}
$q = array name => "Joe",
             interest => "coding",
             homepage => "http://www.google.com"
          );
print qlink$q );

?>
<p>
<a href="anotherpage.php?<? print qlink($q) ?>">Go!</a>
</p>
</body>
</html>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Development
» Query String