Guest User

Untitled

a guest
Jun 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. function build_query($array_data){
  2.  
  3. $data = $array_data;
  4.  
  5. $q = "";
  6. $count = 0;
  7.  
  8. foreach ($data as $key => $d) {
  9. $count ++;
  10. $newVal = explode(' ',$d);
  11. $stringVal = '';
  12.  
  13. if (count($newVal) > 1){
  14. $stringVal = '';
  15. $stringValCount = 0;
  16.  
  17. foreach ($newVal as $newKey => $item) {
  18. $stringValCount++;
  19. $stringVal .= ($stringValCount != count($newVal)) ? $item.'+' : $item;
  20. }
  21.  
  22. }else{
  23.  
  24. $stringVal = $newVal[0];
  25.  
  26. }
  27.  
  28. $q .= ($count != count($data)) ? $key."=".$stringVal.'&' : $key.'='.$stringVal;
  29. }
  30.  
  31. return $q;
  32.  
  33. }
Add Comment
Please, Sign In to add comment