Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:23:58+00:00 2026-05-27T20:23:58+00:00

I was wondering, do too many IF statements bloat coding and when is it

  • 0

I was wondering, do too many IF statements bloat coding and when is it okay not to use them?

These two examples both work the same and I’m the only one editing / using the script. Am I teaching myself bad habits by not adding the IF statement?

if ($en['mm_place']) {
    $tmp = explode(",", $en['mm_place']);
    $en['mm_place'] = $tmp[0].", ".$tmp[1]." ".$tmp[2];
}

is the same as…

$tmp = explode(",", $en['mm_place']);
$en['mm_place'] = $tmp[0].", ".$tmp[1]." ".$tmp[2];

EDIT: using @Francis Avila example I came up with this…

if ($en['mm_wmeet']) {
    $tmp = explode(",", $en['mm_wmeet']);
    for ($i = 0; $i < count($tmp); $i++) {
        $en['mm_wmeet'] = $tmp[$i];
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:23:58+00:00Added an answer on May 27, 2026 at 8:23 pm

    In this particular example, they are not the same.

    If $en['mm_place'] is empty, then $tmp will not have three elements, so your string construction will be bogus.

    Actually what you need is probably this:

    if (!empty($en['mm_place'])) { // depending on whether you know if this is set and must be a string.
        $tmp = explode(',', $en['mm_place'], 3);
        if (count($tmp)===3) {
            $en['mm_place'] = "{$tmp[0]}, {$tmp[1]} {$tmp[2]}";
        }
    }
    

    Run PHP with E_NOTICE set, and code in such a way that you don’t get any notices. PHP requires an extraordinary amount of discipline to use safely and properly because it has so many sloppy misfeatures. Notices will inform you of most bad practices. You will probably end up using lots of if statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just wondering if anyone has had any problems having too many subscribers for
Wondering if there's any not-too-hard way to edit non-form text in html 4. I
I'm currently coding a site in Django (because you can never learn too many
I'm currently coding a site in Django (because you can never learn too many
Im just wondering if I am pushing JSON too far? and if anyone has
After a quick Google I couldn’t find anything too promising so I was wondering
Wondering how to open many new windows with Javascript. I have found plenty of
Just wondering... I find using escape characters too distracting. I'd rather do something like
There are many instances in my work projects where I need to display the
I was wondering how people use tags in emacs when working on a large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.