Im trying to get three functions in to one to mimize the coding, i'm doing this by using a switch. but for some reason its not working, and is outputting all 4 cases at the same time.
I'm calling the function 3 times on my page, each time im putting a different number so it should choose a different case.
But it just outputs "onetwothreefour" and doesn't output $i at all.
I'm calling the function 3 times on my page, each time im putting a different number so it should choose a different case.
But it just outputs "onetwothreefour" and doesn't output $i at all.
PHP:
filefinder('includes/tutorials',1);
filefinder('includes/tutorials',2);
filefinder('includes/tutorials',3);
PHP:
function filefinder($tdir,$i)
{
$adr = $_GET["id"];
$ext = '.php';
$adrext = $adr . $ext;
$dirs = scandir($tdir);
foreach($dirs as $file)
{
if (($file == '.')||($file == '..'))
{
}
elseif (is_dir($tdir.'/'.$file))
{
filefinder($tdir.'/'.$file);
}
if ($file == $adrext)
{
switch ($i) {
case 0:
echo $i; echo "one";
case 1:
echo $i; echo "two";
case 2:
echo $i; echo "three";
case 3:
echo $i; echo "four";
}
}
}
}