Calling php function with exact variables
Lets say we have function that gets 5 variables. 

    function func($var1, $var2, $var3, $var4, $var5 ) 
    {
      if ($var1==1)
      {
        work with $var2, $var3
      }
      if ($var1==2)
      {
        work with $var4, $var5
      }
    }
For example, we want to call this function like that: `func(1,$var2, $var3)` (without unused variables) or like that `func(2,$var4, $var5)`. 

Is it possible? How to send exact variables to php function?

**IN MY CASE**


I have 2 functions for generating dynamic navigation menus from db table


    function menu1($lang, $current)
    {
    	global $db;
    	$result=$db->query("SELECT `id`, `parent`, $lang FROM `nav` WHERE `menu`=$menu");
    		while ($row=$result->fetch_object()){
    			echo '<a ';
    			if($row->id==$current)
    			echo 'class="active"';
    			echo 'href="index.php?id='.$row->id.'">'.$row->$lang.'</a> | ';
    		}
    	}

Call method: `<?=menu1(en, $id)?>` and it generates whole top navigation, makes bold current page


    function menu2($parent, $level){
      global $db;
      $q = $db->query("select * from nav where parent = '$parent'");
      if($level > 0 && $q->num_rows > 0){
        echo "\n<ul>\n";
      }
    while($row=$q->fetch_object()){
        echo "<li>";
        echo '<a href="?page=' . $row->id . '">' . $row->name . '</a>';
        //display this level's children
        menu2($row->id, $level+1);
        echo "</li>\n\n";
    }
      if($level > 0 &&  $q->num_rows > 0){
        echo "</ul>\n";
      }
    }
Call method: `<?=menu2(0, 0)?>` and it generates whole left side navigation, based on parent-child scheme

Now, what I wanna do is, to combine theese 2 functions into 1 function- menu and get something like that

    function menu($menu, $lang, $current, $parent, $level)
    {
    	global $db;
    	if($menu==1){
    		...
    	}
    	if ($menu==2){
    		...
    	}
    }

And to generate two seperate menus from one and only function (for example:  topnav menu call will look like that `<?=menu(1,...)?>`, left menu `<?=menu(2,...)?>`) But have no idea how to get it work. How to push exact variables, etc... Any suggestions? Thx in advance



Calling php function with exact variables
===

Lets say we have function that gets 5 variables. 

    function func($var1, $var2, $var3, $var4, $var5 ) 
    {
      if ($var1==1)
      {
        work with $var2, $var3
      }
      if ($var1==2)
      {
        work with $var4, $var5
      }
    }
For example, we want to call this function like that: `func(1,$var2, $var3)` (without unused variables) or like that `func(2,$var4, $var5)`. 

Is it possible? How to send exact variables to php function?

**IN MY CASE**


I have 2 functions for generating dynamic navigation menus from db table


    function menu1($lang, $current)
    {
    	global $db;
    	$result=$db->query("SELECT `id`, `parent`, $lang FROM `nav` WHERE `menu`=$menu");
    		while ($row=$result->fetch_object()){
    			echo '<a ';
    			if($row->id==$current)
    			echo 'class="active"';
    			echo 'href="index.php?id='.$row->id.'">'.$row->$lang.'</a> | ';
    		}
    	}

Call method: `<?=menu1(en, $id)?>` and it generates whole top navigation, makes bold current page


    function menu2($parent, $level){
      global $db;
      $q = $db->query("select * from nav where parent = '$parent'");
      if($level > 0 && $q->num_rows > 0){
        echo "\n<ul>\n";
      }
    while($row=$q->fetch_object()){
        echo "<li>";
        echo '<a href="?page=' . $row->id . '">' . $row->name . '</a>';
        //display this level's children
        menu2($row->id, $level+1);
        echo "</li>\n\n";
    }
      if($level > 0 &&  $q->num_rows > 0){
        echo "</ul>\n";
      }
    }
Call method: `<?=menu2(0, 0)?>` and it generates whole left side navigation, based on parent-child scheme

Now, what I wanna do is, to combine theese 2 functions into 1 function- menu and get something like that

    function menu($menu, $lang, $current, $parent, $level)
    {
    	global $db;
    	if($menu==1){
    		...
    	}
    	if ($menu==2){
    		...
    	}
    }

And to generate two seperate menus from one and only function (for example:  topnav menu call will look like that `<?=menu(1,...)?>`, left menu `<?=menu(2,...)?>`) But have no idea how to get it work. How to push exact variables, etc... Any suggestions? Thx in advance


