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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.