1
string(1) "5" string(5) "shop2" array(7) { 
    [0]=> array(2) { ["p_name"]=> string(9) "Coca Cola" ["total_qty"]=> string(1) "5" } 
    [1]=> array(2) { ["p_name"]=> string(13) "Fried Chicken" ["total_qty"]=> string(1) "8" } 
    [2]=> array(2) { ["p_name"]=> string(10) "Fried Rice" ["total_qty"]=> string(1) "3" } 
    [3]=> array(2) { ["p_name"]=> string(16) "Fried Vermicelli" ["total_qty"]=> string(1) "5" } 
    [4]=> array(2) { ["p_name"]=> string(13) "Friedn Noodle" ["total_qty"]=> string(1) "5" } 
    [5]=> array(2) { ["p_name"]=> string(5) "Sushi" ["total_qty"]=> string(1) "5" } 
    [6]=> array(2) { ["p_name"]=> string(12) "Test Product" ["total_qty"]=> string(1) "2" } }

Blockquote that the above array name is $itemm..i called that $itemm['p_name'] but i cann't.

Jurina
  • 49
  • 6

2 Answers2

0

You error in $itemm[p_name] You can change to $itemm['p_name']

0

Using your posted input array, this is how you can print the subarray values into table rows:

Code: (Demo)

$itemm=["5",
        "shop2",
        [
            ["p_name"=>"Coca Cola","total_qty"=>"5"],
            ["p_name"=>"Fried Chicken","total_qty"=>"8"],
            ["p_name"=>"Fried Rice","total_qty"=>"3"],
            ["p_name"=>"Fried Vermicelli","total_qty"=>"5"],
            ["p_name"=>"Friedn Noodle","total_qty"=>"5"],
            ["p_name"=>"Sushi","total_qty"=>"5"],
            ["p_name"=>"Test Product","total_qty"=>"2"]
        ]
    ];
foreach($itemm[2] as $rows){
    echo "<tr><td>{$rows['p_name']}</td><td>{$rows['p_name']}</td></tr>\n";
}

Output:

<tr><td>Coca Cola</td><td>Coca Cola</td></tr>
<tr><td>Fried Chicken</td><td>Fried Chicken</td></tr>
<tr><td>Fried Rice</td><td>Fried Rice</td></tr>
<tr><td>Fried Vermicelli</td><td>Fried Vermicelli</td></tr>
<tr><td>Friedn Noodle</td><td>Friedn Noodle</td></tr>
<tr><td>Sushi</td><td>Sushi</td></tr>
<tr><td>Test Product</td><td>Test Product</td></tr>
mickmackusa
  • 43,625
  • 12
  • 83
  • 136
  • @Jurina If this does not reflect the structure of your actual input array, please post a truer sample array in your question. – mickmackusa Sep 10 '17 at 12:38