<?php
$arr = [
"-1:189185464651423744:192578742231801856",
"-2:189186115310424064:192578742231801856",
"-1:189190633304727552:192578739564228608",
"-3:189190753714802688:192578742231801856",
"-2:189190895436177408:192578739828453376",
"-4:189190930895724544:192578739828453376",
"-6:189191536283856896:192578748393238528",
"-1:189192147789123584:192578742231801856",
"-2:189192148765577290:192578742231801856",
"-4:189194591008063488:192578742231801856",
"-5:189194591058407424:192578742231801856",
"-6:189204867351527424:225088212821409792",
"-2:189233507924811776:192578748393238528",
"-1:189233508307398656:192578748393238528",
"-1:189233508310691840:192578748393238528",
"-92:189234657781522432:192578748393238528",
"-13:189234657852964864:192578748393238528",
"-12:189234658243031040:192578748393238528",
"-30:189234805214666752:192578748393238528",
"-1:189234805239906304:192578748393238528",
"-2:189241870793367552:192578748393238528",
"-1:189246041247571968:192578748393238528",
"-26:189248945393004544:192578748393238528",
"-57:189248945632108544:192578748393238528",
"-116:189249106496225280:192578748393238528",
"-2:189249764297306112:192578742231801856",
"-3:189259847830974464:192578739828453376",
"-4:189282780557291520:289805356326277120",
"-2:189469709920776241:192578742231801856",
"-1:189496022886862855:192578748393238528",
"-1:189506522320396295:192578742231801856",
"-1:189514929064419335:257625334765391872",
"-1:189550780146581511:289805356326277120",
"-4:189592029289316425:192578739828453376",
"-5:189592029293510678:192578739828453376",
"-1:231519547530616839:192578739803299840",
"-3:239094787902636039:192578739828453376",
"-1:241212454922399800:253716850322546688"
];
try {
foreach ($arr as $item)
{
$temp = explode(':', $item);
$res[] = [
'specification_id' => $temp[1],
'warehouse_id' => $temp[2],
'supplier_id' => 0,
'value' => abs($temp[0]),
'key' => 'o_p_inventory_qty',
'parent_id' => 0,
'attributes' => [
[
'key' => 'o_p_inventory_attributes_expiry_date',
'language' => 'zh_CN',
'name' => '有效期1',
'value' => '2031-01-01 00:00:00',
]
]
];
}
} catch(\Exception $e) {
echo $e->getMessage();
}
echo json_encode($res,JSON_UNESCAPED_UNICODE);