Jump to content

[SOLVED] Function or Class for use making links. please help me


paulman888888

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.