I got this code, how to insert function & html button inside each array?
<?php
$arr = [
'status' => 1,
'msg' => [
'total_records' => 5,
'total_pages' => 1,
'page_number' => 1,
'per_page' => 100,
'return_count' => 5,
'page_result' => [
0 => [
'items' => 223687201,
'stock' => 'hat',
'stock' => 0,
],
1 => array
(
'items' => 218508001,
'category' => 'bags',
'stock' => 3,
),
2 => array
(
'items' => 180097801,
'category' => 'shirt',
'stock' => 5,
),
3 => array
(
'items' => 178000403,
'category' => 'shirt',
'stock' => 2,
),
4 => array
(
'items' => 200052001,
'category' => 'shoes',
'stock' => 1,
),
],
],
'errcode' => 0,
];
function get_product($array, $search) {
$products = [];
for($i=0; $i < count($array); $i++) {
foreach($array[$i] as $key=>$value) {
if($key == 'category' && $value == $search) {
array_push($products, $array[$i]);
}
}
}
return $products;
}
print_r(get_product($arr['msg']['page_result'], 'shirt'));
?>