shogemuk Posted March 3, 2012 Share Posted March 3, 2012 Hi guy, Does any know how to add a variable value to the name of a function in a loop e.g. $i=1; while($qryRowName = mysql_fetch_assoc($qryName)){ $i++; function test$i(){ ***** } Is this possible? Please any help will be very much aprreciated Thanks } Quote Link to comment https://forums.phpfreaks.com/topic/258195-change-function-name-in-loop/ Share on other sites More sharing options...
scootstah Posted March 3, 2012 Share Posted March 3, 2012 You could use closures, or create_function Quote Link to comment https://forums.phpfreaks.com/topic/258195-change-function-name-in-loop/#findComment-1323512 Share on other sites More sharing options...
PFMaBiSmAd Posted March 3, 2012 Share Posted March 3, 2012 http://us3.php.net/manual/en/functions.variable-functions.php Quote Link to comment https://forums.phpfreaks.com/topic/258195-change-function-name-in-loop/#findComment-1323514 Share on other sites More sharing options...
shogemuk Posted March 3, 2012 Author Share Posted March 3, 2012 Thanks scootstah for the quick reply. How would you use either of those functions to change the name of this function in a loop? function createTemplatedSlide(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 again Quote Link to comment https://forums.phpfreaks.com/topic/258195-change-function-name-in-loop/#findComment-1323515 Share on other sites More sharing options...
shogemuk Posted March 5, 2012 Author Share Posted March 5, 2012 Hi does anyone please know how to solve this. Please any help in how to change this functions name in a loop. function createTemplatedSlide(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 again Quote Link to comment https://forums.phpfreaks.com/topic/258195-change-function-name-in-loop/#findComment-1324056 Share on other sites More sharing options...
trq Posted March 5, 2012 Share Posted March 5, 2012 Explain exactly what it is your trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/258195-change-function-name-in-loop/#findComment-1324062 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.