runeveryday Posted September 14, 2010 Share Posted September 14, 2010 function url($array) { $gets = $_GET; $gets = array_merge($gets,$array); return '?'.http_build_query($gets); } i can't catch up with the above code. hope someone can give me more explaination. as i know, the first is give the GET array to a variable named $gets. then merge it. and return the query string. i don't know why i shoud do this line ($gets = array_merge($gets,$array); ).thank you. Link to comment https://forums.phpfreaks.com/topic/213358-a-function/ Share on other sites More sharing options...
the182guy Posted September 14, 2010 Share Posted September 14, 2010 The benefit of the array_merge() line of code is it enabled you to pass in an array to the function and that array will be appended to the $gets array, and then converted to a query string (along with the $_GET array). If you removed that line then the function would just return the current query string always, the same as returning $_SERVER['QUERY_STRING'] Link to comment https://forums.phpfreaks.com/topic/213358-a-function/#findComment-1110861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.