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 8933787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:37:44+00:00 2026-06-15T09:37:44+00:00

So I am utilizing codeigniter. To allow reusability of code i have a number

  • 0

So I am utilizing codeigniter.

To allow reusability of code i have a number of functions in my model which get different things.

e.g get_details, get_features, get_products

I then have a function called get_all which calls all these methods, so If i want i can get them all but otherwise i can use them individually.

So I have my data, and I pass it to my view. My view loops through each establishment and displays various data in a table row.

At present I use if.. else statements to discern if a value is empty for example.
So if an establishment has not had its features added yet I use:

if(!empty($features['feature1'])){//DO STUFF e.g output 'YES'}

Anyway, my views code is no getting rather long and complicated because essentially for each and every key of each array returned using get_all I am using an if..else statement to output a “-” if it is not set.

It works, it just seems repetitive.

The work around I thought of is to simply set a default array whereby everything is by default set to “-“, then if the data does exist it is overwritten, but then I just have to write/initiate a large default array..

So my question is not a life threatening one, nor is it particularly hard.. I am simply curious as to how one achieves such functionality without ugly code.

Cheers

  • 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-06-15T09:37:45+00:00Added an answer on June 15, 2026 at 9:37 am

    Maybe you can “adjust” the array in the controller, by setting its empty values to -:

    $features = array_map(function($value) {
        return empty($value) ? '-' : $value;
    }, $features);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation utilizing class table inheritance where the base object (which is
I'm using the codeigniter framework and utilizing the uri->segment(); function I have an array:
I have three pages utilizing the same code and on one of the pages
I am utilizing the javax.scripting with Rhino in this project. I have a Java
I'm utilizing the code posted by Jesper Palm here: Make user control display outside
The debug build of some code utilizing SFHFKeychainUtils that is working without complaint on
this is a b-day reminder code utilizing linkedlists typedef struct node { char name[61];
I've been utilizing lots of different corpora for natural language processing, and I've been
I'm utilizing the Reporting Services web service to generate a report and allow the
I am utilizing controls in my asp.net application. I have a register tag the

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.