Main Menu




browser lang:en

Users Area

Client Login

today cache size is:222615

 

Holyguard rss
rss 2.0 for all sections

 

Portfolio

Some of my projects:
CTIBA
MA-NO Web Agency
BluPool
L'Pratone
Travel in Hotel
Yacht Elements
AbruzzoWeb
Il Mastino
CSI Teramo
Innovazione S.p.a.




Comments

John
24/07/2010 by John
better
16/04/2010 by bob
attached files not working !
05/11/2009 by Adnan
Tuvok
14/02/2009 by
Nice script
07/02/2009 by desaj
Other solutions
07/02/2009 by Mike
well
06/02/2009 by holy
Theif
06/02/2009 by

Read More »


RAPIDQ

Rapid-Q:The lost files
My old library where i have collected all the rapidq scripts and italian help


Today my pagerank is: Free Page Rank Tool

Php Getlink:a function that creates links in Php

getLink() is a function that will make creating URLs much easier. This function expects two arguments - the first argument is the URL and the second one is an array with all the parameters that should be passed with the URL. The function will combine the existing URL with the parameter array and return the resulting URL.

One important thing to note is that the final URL will use '&' to separate the parameters instead of just '&'. This is to ensure valid HTML in the output. If you don't like that, just str_replace() it out.

If there is extra parameters in the first URL, that will be present in the final URL.
Arguments

First Argument ($url)
The base URL. The parameters will be added to this.

Second Argument ($params)
An associative array containing all the parameters and their values.

Third Argument ($use_existing_arguments)
This is an optional argument. If this is set to 'true', the function will use the parameters that are present in the current page along with the $params array when creating the URL.

Example Code
Two Arguments



getLink("http://www.google.com/search",array(
		"q"=>"binny",
		"hello"=>"world",
		"results"=>10)
	);

will return
http://www.google.com/search?q=binny&hello=world&results=10
Three Arguments

Assume that the current page is http://www.example.com/index.php?sort_order=name&page=3

getLink("http://www.example.com/edit.php",array(
		"item_id"	=> 15,
		"return_url"=> 'index.php'
	),
true);

This call will return http://www.example.com/edit.php?sort_order=name&page=3&item_id=15&return_url=index.php Code

/**
 * Create a link by joining the given URL and the parameters given as the second argument.
 * Arguments :  $url - The base url.
 *                $params - An array containing all the parameters and their values.
 *                $use_existing_arguments - Use the parameters that are present in the current page
 * Return : The new url.
 * Example : 
 *            getLink("http://www.google.com/search",array("q"=>"binny","hello"=>"world","results"=>10));
 *                    will return
 *            http://www.google.com/search?q=binny&hello=world&results=10
 */
function getLink($url,$params=array(),$use_existing_arguments=false) {
    if($use_existing_arguments) $params = $params + $_GET;
    if(!$params) return $url;
    $link = $url;
    if(strpos($link,'?') === false) $link .= '?'; //If there is no '?' add one at the end
    elseif(!preg_match('/(\?|\&(amp;)?)$/',$link)) $link .= '&'; //If there is no '&' at the END, add one.
    
    $params_arr = array();
    foreach($params as $key=>$value) {
        if(gettype($value) == 'array') { //Handle array data properly
            foreach($value as $val) {
                $params_arr[] = $key . '[]=' . urlencode($val);
            }
        } else {
            $params_arr[] = $key . '=' . urlencode($value);
        }
    }
    $link .= implode('&',$params_arr);
    
    return $link;
}

Rating:
59.0
14 votes
1 2 3 4 5

Comments

really good by

02/11/2008 
i liked this post


Insert your comment

Titolo
Messaggio
Nome Utente
e-mail (se vuoi ricevere le risposte a questo post anche via mail)

Videos


Contents

Selective Tweets Application for Facebook

21/07/2010 

Selective Tweets is an application that allows you to control what tweets are added to your Facebook…

in:Social Networking (0 comments)

FBJS Quick Jump Menu for a FBML Facebook Platform App

15/07/2010 

In a FBML Facebook App, your quick jump menu will require a little tweak to work in FBJS…

in:Scripts and tutorials (0 comments)

How to manage your online reputation, free tools forcommunity managers

02/07/2010 

Every single day, someone, somewhere is discussing something important to your business; your brand, your executives, your…

in:Scripts and tutorials (0 comments)

Genuitec MobiOne Enables Developers to Create Web Apps for the iPhone

28/05/2010 

Although some IT managers are coming around to the idea of supporting iPhones, most aren’t convinced…

in:Free Software (0 comments)

How to configure MX records for incoming SMTP e-mail traffic

27/03/2010 

When you want to run your own mail server, and it does not matter what version and…

in:Apache - .htaccess (0 comments)

Complete guide for Jquery Developers

27/02/2010 

Have you ever had to develop something yourself only to find out that there had already been…

in:JQuery (0 comments)

How can i insert HTML code in my posts?

14/02/2010 

The situation begins with your blog or website and you need to post some code on a particular…

in:The Holy Faq's (0 comments)

12 undocumented tricks for Google Buzz

14/02/2010 

So. Google just recently announced Google Buzz. I’m not sure about you, but I…

in:Blog (0 comments)

Read more »


Tag Clouds


Selective Tweets Application FacebookFBJS Quick Jump Menu FBML Facebook Platform AppHow manage your online reputation free tools forcommunity managersGenuitec MobiOne Enables Developers Create Apps iPhoneHow configure records incoming SMTP email


Add to Technorati Favorites