spires Posted May 13, 2011 Share Posted May 13, 2011 Hi How do I turn this: if($LCname=='Business_solutions'){ $newChild = Business_solutions::find_by_id(1); } In to something like this: $newChild = $LCname::find_by_id(1); I'm calling lots of class's, and want to make it more dynamic. The 2nd example would be perfect, but that does not work. Is there an alternative? Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted May 13, 2011 Share Posted May 13, 2011 call_user_func if (in_array($LCname, array("Business_solutions"))) { // for security $newChild = call_user_func($LCname . "::find_by_id", 1); } Quote Link to comment Share on other sites More sharing options...
spires Posted May 13, 2011 Author Share Posted May 13, 2011 Hi, Thanks for your help. I've not come across that before. I'm trying: if (in_array($LCname, array("Business_solutions_cat"))) { // for security $newChild = call_user_func($LCname . "::find_by_id", 1); foreach($newChild as $newChilds){ echo $newChilds->id; } } but nothing is echoing. Am I missing some code? Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted May 13, 2011 Share Posted May 13, 2011 Maybe. What does print_r(Business_solutions_cat::find_by_id(1)); output? Quote Link to comment 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.