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

  • Home
  • SEARCH
  • 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 8819405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:21:01+00:00 2026-06-14T05:21:01+00:00

Here is a var_dump or an array returned from my MODEL: array (size=5) 0

  • 0

Here is a var_dump or an array returned from my MODEL:

array (size=5)
  0 => 
    array (size=3)
      0 => 
        object(stdClass)[19]
          public 'X_SIZE' => string '1.75x3' (length=6)
      1 => 
        object(stdClass)[20]
          public 'X_SIZE' => string '1.75x3.5(slim)' (length=14)
      2 => 
        object(stdClass)[21]
          public 'X_SIZE' => string '2x3' (length=3)
  1 => 
    array (size=3)
      0 => 
        object(stdClass)[17]
          public 'X_PAPER' => string '14ptGlossCoatedCoverwithUV(C2S)' (length=31)
      1 => 
        object(stdClass)[18]
          public 'X_PAPER' => string '14ptPremiumUncoatedCover' (length=24)
      2 => 
        object(stdClass)[24]
          public 'X_PAPER' => string '16ptDullCoverwithMatteFinish' (length=28)
  2 => 
    array (size=2)
      0 => 
        object(stdClass)[23]
          public 'X_COLOR' => string '1000' (length=4)
      1 => 
        object(stdClass)[22]
          public 'X_COLOR' => string '1002' (length=4)
  3 => 
    array (size=4)
      0 => 
        object(stdClass)[26]
          public 'X_QTY' => string '100' (length=3)
      1 => 
        object(stdClass)[25]
          public 'X_QTY' => string '250' (length=3)
      2 => 
        object(stdClass)[29]
          public 'X_QTY' => string '500' (length=3)
      3 => 
        object(stdClass)[30]
          public 'X_QTY' => string '1000' (length=4)
  4 => 
    array (size=3)
      0 => 
        object(stdClass)[28]
          public 'O_RC' => string 'YES' (length=3)
      1 => 
        object(stdClass)[27]
          public 'O_RC' => string 'NO' (length=2)
      2 => 
        object(stdClass)[33]
          public 'O_RC' => string 'NA' (length=2)

My controller is sending to my view and on my view the above dump is of: var_dump($printerOptions)

Ok so I need to create a dropdown menu for each of these arrays and radio buttons for the O_RC array.

I am using codeigniter and using form_dropdown('',$val); inside of a foreach loop causes multiple dropdowns for each key and element in the array.

foreach ($printerOptions as $Options) 
{
//var_dump($Options);
    foreach ($Options as $Specs) 
    {
        echo $Specs->X_SIZE;
        echo $Specs->X_PAPER;
        echo $Specs->X_COLOR;
        echo $Specs->X_QTY;
        echo $Specs->O_RC;
    }
}

This ^ code will echo out the expected values of the corresponding arrays but for some reason I get LOOPING errors with the output:

Undefined property: stdClass::$X_PAPER
Undefined property: stdClass::$X_COLOR
Undefined property: stdClass::$X_QTY
Undefined property: stdClass::$O_RC

Looking at my array how can I create a dropdown menu for each of the arrays respectively?

Thanks for the help.

MODEL /// Update ///

class M_Pricing extends CI_Model {

    function get_prices() 
    {
        $table_by_product = 'printer_businesscards'; //replace with URI Segment
        
        //Get all the columns in the table set by the page URI of $table_by_product variable 
        $get_all_col_names = $this->db->list_fields($table_by_product);
        
        //Loop through the column names. All names starting with 'O_' are optional fields for the 
        //current product. Get all Distinct values and create a radio button list in form.
        $resultArray = array();
        
        foreach ($get_all_col_names as $key => $value) {
            //get all o_types for the product by column name
            if (preg_match('/O_/', $value)) 
                {
                $v = (array('Specs' => $value));
                foreach ($v as $vals) {
                    $this->db->select($vals);
                    $this->db->distinct();
                    $qX = $this->db->get($table_by_product);
                    $resultArray[] = $qX->result();
                    }
                } 
            
            //Get all x_types for the product by column name. All 'X_' types are specific product options.
            //Create a dropdown menu with all DISTINCT product options. 
            if (preg_match('/X_/', $value)) 
                {
                $v = (array('Type' => $value));
                foreach ($v as $vals) {
                    $this->db->select($vals);
                    $this->db->distinct();
                    $qX = $this->db->get($table_by_product);
                    $resultArray[] = $qX->result();
                    }
                }       
        }
        //return $resultArray
        //var_dump($resultArray); die;
        return $resultArray;
    }
  • 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-14T05:21:02+00:00Added an answer on June 14, 2026 at 5:21 am

    As i understand your result array should be object or hash and look like:

    array('Type'=>array(
       'X_SIZE'=>array('1.75x3','1.75x3.5(slim)','2x3'),
       'X_PAPER'=>array('14ptGlossCoatedCoverwithUV(C2S)','14ptPremiumUncoatedCover'),
    ///...),
    'Specs'=>array(
    

    //…)
    );

    to loop through such structure:

    //Types
    echo 'Types';
    foreach ($Options['Types'] as $type=>$values) {
    echo $type;
    echo "<select>";
    foreach ($values as $value) {
    echo "<option value="$value">$value</option>";
    }
    echo "</select>";
    }
    
    //Specs
    echo 'Specs';
    foreach ($Options['Specs'] as $type=>$values) {
     echo $type;
     echo "<select>";
     foreach ($values as $value) {
       echo "<option value="$value">$value</option>";
     }
     echo "</select>";
    }
    

    model:

    <?php
    class M_Pricing extends CI_Model {
    
        function get_prices() 
        {
            $table_by_product = 'printer_businesscards'; //replace with URI Segment
    
            //Get all the columns in the table set by the page URI of $table_by_product variable 
            $get_all_col_names = $this->db->list_fields($table_by_product);
    
            //Loop through the column names. All names starting with 'O_' are optional fields for the 
            //current product. Get all Distinct values and create a radio button list in form.
    
            $resultArray=array();
            $resultArray['Options']=array();
            $resultArray['Specs']=array();
    
            foreach ($get_all_col_names as $key => $value) {
                //get all o_types for the product by column name
                $opt_type="";
                if (preg_match('/O_/', $value)) {$opt_type="Options";} elseif
                   (preg_match('/X_/', $value)) {$opt_type="Specs";} else {continue;}
                   if (!isset($resultArray[$opt_type][$value])) {$resultArray[$opt_type][$value]=array();}
                        $this->db->select($value);
                        $this->db->distinct();
                        $qX = $this->db->get($table_by_product);
                        foreach ($qX->result() as $v) {
                         $resultArray[$opt_type][$value][]=$v->$value;
                        }
               }      
    
            //return $resultArray
            //var_dump($resultArray); die;
            return $resultArray;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my var_dump: array(2) { [1]=> object(stdClass)#382 (3) { [name]=> string(12) Other fields
Here is the result of var_dump($my_var[id]) on the object I'm having issues with: array(1)
Here is a var_dump of a multidimensional array. array (size=2) 'ad795f9b369fc967db8fe0611ecc3cb3' => array (size=6)
Here is my string $newPath = '/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js'; Now check this output var_dump($newPath); // string(64)
I am parsing the XML returned from Google Map API V3. Here is the
Can anyone tell me what is happening here? <?php // true var_dump('\\ ' ===
Quoted from here : If delimiter contains a value that is not contained in
I'm trying to create an array, looping through another array and taking the string
Is there a limit on a value string in php Associative array? I have
I'm calling either var_dump() or print_r() on an array that has one value in

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.