Page 1 of 1

Change Function name in a loop

Posted: Mon Mar 05, 2012 3:21 am
by shogemuk
Hi Guys,
Does any know how to add a variable value to the name of the following function in a loop

Code: Select all

$i=1;
while($qryRowName = mysql_fetch_assoc($qryName)){
$i++;
function createTemplatedSlide$i(PHPPowerPoint $objPHPPowerPoint)
{
   // Create slide
   $slide = $objPHPPowerPoint->createSlide();

   // Add background image
    $slide->createDrawingShape()
          ->setName('Background')
          ->setDescription('Background')
          ->setPath('./images/realdolmen_bg.jpg')
          ->setWidth(950)
          ->setHeight(720)
          ->setOffsetX(0)
          ->setOffsetY(0);

    // Add logo
    $slide->createDrawingShape()
          ->setName('PHPPowerPoint logo')
          ->setDescription('PHPPowerPoint logo')
          ->setPath('./images/phppowerpoint_logo.gif')
          ->setHeight(40)
          ->setOffsetX(10)
          ->setOffsetY(720 - 10 - 40);

    // Return slide
    return $slide;
}
}
Thanks in advance

Re: Change Function name in a loop

Posted: Mon Mar 05, 2012 3:45 am
by requinix
Don't define the function in the loop. Leave it outside where it belongs.

Re: Change Function name in a loop

Posted: Mon Mar 05, 2012 5:04 am
by shogemuk
thanks for the reply tasairis,
I need to be able to create this function dynamically in a loop in order to change the values within in.

Re: Change Function name in a loop

Posted: Mon Mar 05, 2012 2:16 pm
by requinix
shogemuk wrote:I need to be able to create this function dynamically in a loop in order to change the values within in.
No, you don't. Whatever you're talking about does not require defining multiple functions like that.

Care to explain more about what you're trying to do?