How to print associative array in codeigniter












0















my controller is : **



public function getdatewiseOrder()
{


$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));

$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;

}



$this->data['order'] = $order;
$this->data['item'] = $item;

$this->render_template('reports/leser_report', $this->data);
}




for check : after print_r of item variable i get data in this format:



Array ( 
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)

)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)


I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use




  • $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
    $enddate);


for fetching data from order_item i am using





  • $item[$x] = $this->model_reports->getorderItem($value['id']);



    inside foreach loop         



I want output in this format
enter image description here










share|improve this question




















  • 1





    So you have an array of associative arrays. What's the question?

    – Jamie_D
    Nov 20 '18 at 9:38











  • Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.

    – Colin Cline
    Nov 20 '18 at 9:39











  • Please add echo <pre>; before print_r() function used. If you just want to show the item variable

    – Madhuri Patel
    Nov 20 '18 at 9:40













  • Also, it depends on that why you want to print the array?

    – Danish Ali
    Nov 20 '18 at 10:16











  • I want show order details and order item details in view page and i have two table orders and order_item

    – sumit saim
    Nov 20 '18 at 12:32
















0















my controller is : **



public function getdatewiseOrder()
{


$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));

$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;

}



$this->data['order'] = $order;
$this->data['item'] = $item;

$this->render_template('reports/leser_report', $this->data);
}




for check : after print_r of item variable i get data in this format:



Array ( 
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)

)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)


I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use




  • $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
    $enddate);


for fetching data from order_item i am using





  • $item[$x] = $this->model_reports->getorderItem($value['id']);



    inside foreach loop         



I want output in this format
enter image description here










share|improve this question




















  • 1





    So you have an array of associative arrays. What's the question?

    – Jamie_D
    Nov 20 '18 at 9:38











  • Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.

    – Colin Cline
    Nov 20 '18 at 9:39











  • Please add echo <pre>; before print_r() function used. If you just want to show the item variable

    – Madhuri Patel
    Nov 20 '18 at 9:40













  • Also, it depends on that why you want to print the array?

    – Danish Ali
    Nov 20 '18 at 10:16











  • I want show order details and order item details in view page and i have two table orders and order_item

    – sumit saim
    Nov 20 '18 at 12:32














0












0








0








my controller is : **



public function getdatewiseOrder()
{


$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));

$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;

}



$this->data['order'] = $order;
$this->data['item'] = $item;

$this->render_template('reports/leser_report', $this->data);
}




for check : after print_r of item variable i get data in this format:



Array ( 
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)

)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)


I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use




  • $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
    $enddate);


for fetching data from order_item i am using





  • $item[$x] = $this->model_reports->getorderItem($value['id']);



    inside foreach loop         



I want output in this format
enter image description here










share|improve this question
















my controller is : **



public function getdatewiseOrder()
{


$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));

$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;

}



$this->data['order'] = $order;
$this->data['item'] = $item;

$this->render_template('reports/leser_report', $this->data);
}




for check : after print_r of item variable i get data in this format:



Array ( 
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)

)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)


I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use




  • $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
    $enddate);


for fetching data from order_item i am using





  • $item[$x] = $this->model_reports->getorderItem($value['id']);



    inside foreach loop         



I want output in this format
enter image description here







arrays codeigniter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 6:55







sumit saim

















asked Nov 20 '18 at 9:22









sumit saimsumit saim

43




43








  • 1





    So you have an array of associative arrays. What's the question?

    – Jamie_D
    Nov 20 '18 at 9:38











  • Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.

    – Colin Cline
    Nov 20 '18 at 9:39











  • Please add echo <pre>; before print_r() function used. If you just want to show the item variable

    – Madhuri Patel
    Nov 20 '18 at 9:40













  • Also, it depends on that why you want to print the array?

    – Danish Ali
    Nov 20 '18 at 10:16











  • I want show order details and order item details in view page and i have two table orders and order_item

    – sumit saim
    Nov 20 '18 at 12:32














  • 1





    So you have an array of associative arrays. What's the question?

    – Jamie_D
    Nov 20 '18 at 9:38











  • Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.

    – Colin Cline
    Nov 20 '18 at 9:39











  • Please add echo <pre>; before print_r() function used. If you just want to show the item variable

    – Madhuri Patel
    Nov 20 '18 at 9:40













  • Also, it depends on that why you want to print the array?

    – Danish Ali
    Nov 20 '18 at 10:16











  • I want show order details and order item details in view page and i have two table orders and order_item

    – sumit saim
    Nov 20 '18 at 12:32








1




1





So you have an array of associative arrays. What's the question?

– Jamie_D
Nov 20 '18 at 9:38





So you have an array of associative arrays. What's the question?

– Jamie_D
Nov 20 '18 at 9:38













Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.

– Colin Cline
Nov 20 '18 at 9:39





Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.

– Colin Cline
Nov 20 '18 at 9:39













Please add echo <pre>; before print_r() function used. If you just want to show the item variable

– Madhuri Patel
Nov 20 '18 at 9:40







Please add echo <pre>; before print_r() function used. If you just want to show the item variable

– Madhuri Patel
Nov 20 '18 at 9:40















Also, it depends on that why you want to print the array?

– Danish Ali
Nov 20 '18 at 10:16





Also, it depends on that why you want to print the array?

– Danish Ali
Nov 20 '18 at 10:16













I want show order details and order item details in view page and i have two table orders and order_item

– sumit saim
Nov 20 '18 at 12:32





I want show order details and order item details in view page and i have two table orders and order_item

– sumit saim
Nov 20 '18 at 12:32












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389797%2fhow-to-print-associative-array-in-codeigniter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389797%2fhow-to-print-associative-array-in-codeigniter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]