<?php
$_POST = ['VAL0' => 'TESTING', 'UNIT0' => '99', 'VAL1' => 'TESTING1', 'UNITS1' => '88'];
$bulkProducts = array();
foreach ($_POST as $key => $value) {
if (strpos($key, "VAL")===0) {
$val= $value;
}
if (strpos($key, "UNIT")===0) {
$newunits= $value;
}
if (isset($val,$newunits)) {
$products = array();
$products = array(
'VAL' => $val,
'UNITS' =>$newunits
);
array_push($bulkProducts,$products);
}
}
print_r($bulkProducts);
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- Array
(
[0] => Array
(
[VAL] => TESTING
[UNITS] => 99
)
[1] => Array
(
[VAL] => TESTING1
[UNITS] => 99
)
[2] => Array
(
[VAL] => TESTING1
[UNITS] => 88
)
)
preferences:
183.42 ms | 405 KiB | 213 Q