PHP Function to Create URLs


$url = 'http://maheshbokkisam.blogspot.com/create_url.php';

$data = array("a"=>1, "b"=>3, "c"=>'');

_make_url($url, $data);


/** 

 * Create url with url and uri 

 * @param url and uri data (array)

 * return string (url) 

*/

function _make_url($url='http://'.$_SERVER['SERVER_NAME'], $data){

$data = array_diff($data, array(''=>'')); 

              // remove empty keys from uri data array

               return (count($data) > 0) ? $url.'?'.http_build_query($data, 'flags_') : $url;

}

Comments

Popular posts from this blog

AIOMgr: Preparing flush failed with VERR_NOT_SUPPORTED, disabling async flushes

Create Virtual Host in IIS Server

The model type is invalid. please select an item from the list ( ASP.Net MVC)