Jump to content

Access values in an array


skicrud

Recommended Posts

I have created the following function:

function get_prepress_checked_items($job_number){

        $checked_items=array();

        $sql='SELECT * from rs_prepress_log where job_number='.sprintf('%d',$job_number);

        $query=$this->db->query($sql);

        $query->result_array(); 

        //$rtn=$query->result(); #returns the results from the log file   

      // $checked_items=array();

        foreach($query->result_array() as $row)

        {

        $checked_items[]=$row['item_checked'];

        $checked_items[]=$row['item_comment'];

           

        }

 

        return $checked_items;

    }

when I execute the following code

echo '<pre>';var_dump($checked_items);echo '</pre>';

 

I get back:

array(4) {

  [0]=>

  string(3) "A00"

  [1]=>

  string(9) "comment 1"

  [2]=>

  string(3) "A20"

  [3]=>

  string(9) "comment 2"

}

My question is how do I set up a loop to get the "comment 1" and "comment 2" variables? ;D

Link to comment
https://forums.phpfreaks.com/topic/153329-access-values-in-an-array/
Share on other sites

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.