paulman888888 Posted May 24, 2009 Share Posted May 24, 2009 Hi; 1st of all thankyou for reading this. I am trying to make a function that will keep looping lots of variables thats passed to it. Let me explain; function make_link($a1,$a2, $b1,$b2, how do i make a loop that will get all passed to it? sometimes just 1 is passed and other times upto 20){ //now another loop i think i will need to use foreach but dont know how $returnme='index.php?'; foreach(somecode here not sure what){ $returnme.=$a1.'='$a2.'&'; }return $returnme;} in more detail each letter has 2 parts, 1 and 2 1=variable name 2=variable value the reason i want to do this is incase i want to use .htaccess and it would be much easyier generate links than to go change them all myself. Thankyou Paul Link to comment https://forums.phpfreaks.com/topic/159469-solved-function-or-class-for-use-making-links-please-help-me/ Share on other sites More sharing options...
papaface Posted May 24, 2009 Share Posted May 24, 2009 function theLooper($vars) { if (is_array($vars)) { foreach ($vars as $k => $v) { //do something } } else { echo "not an array of values"; } } theLooper(array("Name" => "Andrew","Age" => "20")); Do you mean like that? Link to comment https://forums.phpfreaks.com/topic/159469-solved-function-or-class-for-use-making-links-please-help-me/#findComment-841187 Share on other sites More sharing options...
paulman888888 Posted May 24, 2009 Author Share Posted May 24, 2009 yes thanks. I learnt something new thanks again Link to comment https://forums.phpfreaks.com/topic/159469-solved-function-or-class-for-use-making-links-please-help-me/#findComment-841256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.