php - Getting the highest element from an array -


let me explain doing

i have query gives me tuple of discount added database.

here's query

$discount_info = $this->autoload_model->get_data_from_table("td_discount,td_userdiscount","*",                                                "td_discount.discount_id = td_userdiscount.discount_id                                                 , td_discount.discount_code = '$coupon'")->result_array(); 

now have script specific function.

there condition, if value of index 1, code snippet this

if($discount_info[0]['discount_on']=="3")     {         $discount_product = $discount_info[0]['discount_product']; // id(autoincrement value)//         if($discount_info[0]['applicable_type']==1)         {             $item_info = $this->autoload_model->get_data_from_table("td_product","*","product_id = '$discount_product'")->result_array();             foreach($this->cart->contents() $ci)             {                 if($ci['name'] = $item_info[0]['product_name']                 {                     // cart_item highest price if product name matches//                 }             }         }     } 

my cart structure this

$data = array(                 'id'      => $id,                 'qty'     => $qty,                 'price'   => $price,                 'name'    => $name,                 'options' => array(                                     'picture'=>$img,                                     'item_slug'=>$slug,                                     'item_color'=>$color,                                     'item_size'=>$size,                                     'unit_price'=>$price,                                     'order_type'=>$order_type,                                     'product_type'=>$pro_type,                                     'unit_discount' => 0.00,                                     'item_discount' => 0.00,                                     'discount_type' => '',                                     )                 ); 

now, set up, cant login shall put on here

// cart_item highest price if product name  

can me in achieveing this

thanks in advance

i imagine define

$highest = array('price' => 0); 

before loop , inside loop go:

// cart_item highest price if product name matches// if ($ci['price'] > $highest['price']) {     $highest = $ci; } 

that way $highest contain best match @ end.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -