Jump to content

Return... and foreach question...


Aureole

Recommended Posts

Is it not possible to return more than one thing from a function? I tried...

 

return $var, $anothervar; and I get an unexpected "," error.

 

If it's not possible then instead is it possible to do... well, I have this:

 

<?php
foreach($player_stats as $prop => $val)
{
    $formatprop = '<p class="content"><strong>'.htmlentities($prop, ENT_QUOTES).'</strong></p>';
    $formatval = '<p class="content">'.htmlentities($val, ENT_QUOTES).'<p>';
?>
<tr>
<td width="30%" class="black_td"><?php echo $formatprop; ?></td>
<td width="70%" class="gray_td"><?php echo $formatval; ?></td>
</tr>
<?php
}
?>

 

...but I want the foreach to ignore $player_stats['length'], to skip it. Ignore it then go through the rest.

 

Maybe like...

 

<?php
foreach($player_stats as $prop => $val)
{
    if($prop !== 'length')
    {
        $formatprop = '<p class="content"><strong>'.htmlentities($prop, ENT_QUOTES).'</strong></p>';
        $formatval = '<p class="content">'.htmlentities($val, ENT_QUOTES).'<p>';
        // Etc.
    }
}

 

...or is there a better way?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.