Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/12/2018, 11:52
alvaro_trewhela
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: borrar una variable de una url

Código PHP:
Ver original
  1. function deleteGet($url, $get){
  2. $split = explode("?", $url); //split the url
  3. $getPart = $split[1]; //get the get part
  4. $gets = explode("&", $getPart); //get all gets
  5. $newUrl = $split[0]."?"; //new url must be first part concat to character "?"
  6.     for($k=0;$k<sizeof($gets);$k++){ //we check al gets...
  7.     $data = explode("=", $gets[$k]); //separating the var from the value
  8.         if($data[0] != $get) //if the var is not eq. to the deleting get then...
  9.             $newUrl .= $gets[$k]; //concat to new url
  10.         if($k+1 < sizeof($gets)) //if is not the last element...
  11.             $newUrl .= "&"; //add character "&"
  12.     }
  13. return $newUrl; //we return the newUrl
  14. }

Código PHP:
Ver original
  1. $nUrl = deleteGet("administracion.php?modAdministracion=administracio n&bajaCliente=bajaCliente", "bajaCliente");

No lo probé puede tener errores, pero espero se entienda que es lo que hice