Hey this could be the sort of challenge someone likes if they have never done but. Right now I'm pretty much stuck however. If you look at the foreach loop below you will see that the function has $i at the end of it. I'm trying to use eval to make this happen but I get all the usual T Variable errors and unexpected characters etc
Anyone got any ideas? This is for a plugin, won't release details but if someone gives me a fix I'll put your name and site as a contributor permanent so you will get some traffic from it. Best I can do, cheers all.
foreach ($result as $result)
{
eval ('
function wpblogs_iframeadmin_sublevel_page_$i()
{ ?>
<iframe src ="http://www.webtechglobal.co.uk" width="100%" height="1700px">
<p>Your browser does not support iframes.</p>
</iframe>
<?php
}
');
$i++;
}
Page 1 of 1
Loop to echo function using eval and incremental number List of functions with 1 digit difference but how?
#2
Posted 30 July 2009 - 08:36 PM
Because you can use variable function names, I would do it something like this:
I wouldn't bother with eval() tbh
I wouldn't bother with eval() tbh
$i = 1;
foreach ($results as $result)
{
$my_func_name = 'wpblogs_iframeadmin_sublevel_page_'.$i;
$my_func_name()
{
#function code here...
}
$i++;
}
- ← Echoing mysql values into a text box
- Server Side (PHP, Databases, ASP.NET, etc)
- An easy to implement ASP contact form? →
Share this topic:
Page 1 of 1
Help

















