PHP Sorgu Dize Manipülasyon

0 Cevap php

Any one have the ultimate PHP function(s) to add/remove parameters from a query string? It needs to handle all possible cases, Ive seen ones that handle some cases, but not all.

Bazı örnek vakalar:

Bu ideal gibi bir şey olmalıdır:

function add_get_param($uri, $name, $value = null) { ... }
function remove_get_param($uri, $name) { ... }

Bazı örnek testler:

$var = add_get_param('http://mysite.com?param1=1&param2=2', 'param3', 3);
// http://mysite.com?param1=1&param2=2&param3=3

ve:

$var = add_get_param('/dir/ Sayfa.html? Param1 = 1&param2=2#jump_to_bottom', 'param3');
// /dir/ Sayfa.html? Param1 = 1&param2=2&param3#jump_to_bottom

vs ..

Alright, I wrote my own functions:

PHP: http://pastebin.org/170157 jQuery: http://pastebin.org/169981

0 Cevap