Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Quest abou function + foreach ?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Quest abou function + foreach ?

Postby BigBoyFoF » Sat Oct 13, 2012 8:34 am

Well,

I have created a function but in that function there are foreach runs ...

is it posible to return a variable out of the function & foreach run ?

i would like to get out $counter ?
Code: Select all
function viewFoto($nDir, $iCurrent = 0)
{
    if(!is_array($nDir))
    {
        return false;
    }
   $sReturn = '';
   $counter = 0;
      foreach($nDir as $iKey => $sValue)
      {
         if(is_array($sValue))
         {
            echo "<img src='".$iKey."/".$sValue."'></img>";
         } else
         {           
               echo "<li><a href='Project/".$_GET["id"]."/".$sValue."' rel='lightbox[". $_GET["id"] ."]'><img src='Project/".$_GET["id"]."/".$sValue."' id='showFoto'></img></li></a>\n";
            $counter = $counter + 300;
         }
      }
   
   return;
}
BigBoyFoF
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Oct 13, 2012 4:15 am

Re: Quest abou function + foreach ?

Postby MeroD » Sun Oct 14, 2012 11:32 pm

MeroD
New php-forum User
New php-forum User
 
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron