Posted By

alberomo on 10/01/11


Tagged

get php classroom LaVioleta


Versions (?)

getVars Function for PHP.


 / Published in: PHP
 

Transform $GET or $POST in a string to add to an URL and send variables and values. Argument: Receive an $GET O $POST array function. Returns: variables concatenation to add to the URL.

  1. function getVars($arrVars){
  2. $txtGetVars='';
  3. foreach ($arrVars as $Key=>$Value){
  4. if (gettype($Value)=='array'){
  5. for($k=0; $k <= count($arrVars[$Key])-1;$k++){
  6. $txtGetVars .= ($txtGetVars=='')? $Key.'[]='$arrVars[$Key][$k] :'&'.$Key.'[]='.$arrVars[$Key][$k];
  7. }
  8. else{
  9. $txtGetVars .=($txtGetVars=='')? $Key.'='.$Value :'&'.$Key.'='.$Value ;
  10. }
  11. }
  12. }
  13. return $txtGetVars;
  14.  
  15. }

Report this snippet  

You need to login to post a comment.