-1

How to extract this multi dimensional array from php. I am using codeigniter framework.

   array(2) {
    [0] => array(14)
    {
    ["Key"] => 
      string(48) "32;FaXmBQJ7/0MATwBVAFAAMAAxADIAOA==9;1261414580;"
      ["Type"] => string(12) "Store_Coupon"
      ["Code"] => string(8) "COUP0128"
      ["Coupon_Issuer"] => string(2) "11"
      ["Coupon_Reference_No"] => string(1) "1"
      ["Description"] => string(5) "test2"
      ["Price_Group"] => string(3) "ALL"
      ["Discount_Type"] => string(15) "Discount_Amount"
      ["Discount_Value"] => string(1) "0"
      ["Validation_Period_ID"] => string(2) "14"
      ["Validation_Description"] => string(15) "2016 membership"
      ["Starting_Date"] => string(10) "2016-01-01"
      ["Ending_Date"] => string(10) "2016-12-31"
      ["Status"] => string(8) "Disabled"
    }

  [1] => array(14)
    {
    ["Key"] => string(48) "32;FaXmBQJ7/0MATwBVAFAATwBOADAAMg==9;1261413680;"
    ["Type"] => string(12) "Store_Coupon"
    ["Code"] => string(8) "COUPON02"
    ["Coupon_Issuer"] => string(2) "11"
    ["Coupon_Reference_No"] => string(1) "2"
    ["Description"] => string(6) "test 3"
    ["Price_Group"] => string(3) "ALL"
    ["Discount_Type"] => string(16) "Discount_Percent"
    ["Discount_Value"] => string(1) "0"
    ["Validation_Period_ID"] => string(2) "14"
    ["Validation_Description"] => string(15) "2016 membership"
    ["Starting_Date"] => string(10) "2016-01-01"
    ["Ending_Date"] => string(10) "2016-12-31"["Status"] => string(8) "Disabled"
    }
}

I want to extract Coupon_Reference_No element. Thanks in advance

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
coolshox
  • 95
  • 1
  • 12
  • 1
    Possible duplicate of [How can I access an array/object?](http://stackoverflow.com/questions/30680938/how-can-i-access-an-array-object) – Andrew Myers Jun 10 '16 at 03:59

1 Answers1

1

Just do a foreach and store that variable in an array. Supposing your aray is $array

$Coupon_Reference_No = array();
foreach($array as $key=>$value){
 if($key == 'Coupon_Reference_No'){
   $Coupon_Reference_No[] = $value;
 }
}

You will get an array $Coupon_Reference_No as array("1","2")

Amit Ray
  • 3,445
  • 2
  • 19
  • 35
  • Hi @Amit Ray Thanks for the answer. I will try this. i try array_column($result, 'Coupon_Reference_No'); much simpler Thank you – coolshox Jun 10 '16 at 02:36