Return to Snippet

Revision: 10587
at January 5, 2009 09:45 by sveggiani


Initial Code
// name:		evAddParamURL
// version:		v0.1
// description:		agrega (o reemplaza si existe) un parametro en una URL

function evAddParamURL( $url, $key, $value ) {

	$url = preg_replace( '/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&' );
	$url = substr( $url, 0, -1 );

	if ( strpos( $url, '?' ) === false ) {
		return ( $url . '?' . $key . '=' . $value );
	} else {
		return ( $url . '&' . $key . '=' . $value );
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
evAddParamURL | adds a param to a given URL and returns the new URL

Initial Tags

                                

Initial Language
PHP