Jump to content

Is this syntax correct?


unemployment

Recommended Posts

I'm not sure how to format the 'if (empty($otherfans)' part.  What's the cleanest way to do this?

 

$data[0][$k]['message'] = 'You have successfully joined <a href="../c/'.$r['companytag'].'">'.$r['feedfirstname'].'</a> in '.industry($r['industry']).' at '.stage($r['stage']).' stage'.if (empty($otherfans)){"."};

Link to comment
https://forums.phpfreaks.com/topic/238873-is-this-syntax-correct/
Share on other sites

in situations like this, i prefer using variable interpolation, like so

$data[0][$k]['message'] = 'You have successfully joined <a href="../c/'.$r['companytag'].'">{$r['feedfirstname']}</a> in {industry($r['industry'])} at {stage($r['stage'])} stage{if (empty($otherfans))}.';

in situations like this, i prefer using variable interpolation, like so

$data[0][$k]['message'] = 'You have successfully joined <a href="../c/'.$r['companytag'].'">{$r['feedfirstname']}</a> in {industry($r['industry'])} at {stage($r['stage'])} stage{if (empty($otherfans))}.';

 

You put the period outside of the if.  I need it to say if otherfans is empty then add a period.  Is what you did correct?

in situations like this, i prefer using variable interpolation, like so

$data[0][$k]['message'] = 'You have successfully joined <a href="../c/'.$r['companytag'].'">{$r['feedfirstname']}</a> in {industry($r['industry'])} at {stage($r['stage'])} stage{if (empty($otherfans))}.';

 

You put the period outside of the if.  I need it to say if otherfans is empty then add a period.  Is what you did correct?

ah, wasnt sure of what you were trying to accomplish.. I believe that instead of placing the if statement inside of your string, before you declare $data[0][$k]['message'], make an if statement with a variable, then simply call the variable in your string..e.g

if(empty($otherfans))
{
$period = ".";
}else
{
$period = "";
}

then simply call the variable at the end of your string.

$data[0][$k]['message'] = 'You have successfully joined <a href="../c/'.$r['companytag'].'">{$r['feedfirstname']}</a> in {industry($r['industry'])} at {stage($r['stage'])} stage{$period}';

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.