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
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))}.';

Link to comment
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))}.';

 

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?

Link to comment
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))}.';

 

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}';

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.