$arr = [
[
"answer_schema_id" => "1",
"content" => "odpowiedz 1",
"locale" => "pl",
"points" => "3",
"answerKey" => "1",
"answerElementOrder" => "1",
"image" => "5cd143beba821203428009.jpg",
], [
"answer_schema_id" => "1",
"content" => "answer 1",
"locale" => "en",
"points" => "3",
"answerKey" => "1",
"answerElementOrder" => "1",
"image" => "5cd143beba821203428009.jpg",
], [
"answer_schema_id" => "2",
"content" => "answer 2",
"locale" => "en",
"points" => "2",
"answerKey" => "2",
"answerElementOrder" => "2",
"image" => "5cd143bebcdfc405126844.jpg",
], [
"answer_schema_id" => "2",
"content" => "odpowiedz 2",
"locale" => "pl",
"points" => "2",
"answerKey" => "2",
"answerElementOrder" => "2",
"image" => "5cd143bebcdfc405126844.jpg",
]
];
$result = [];
$ptr = [];
foreach ($arr as $el) {
if (!isset($ptr[$el['answer_schema_id']])) {
$res[] = [
"answer_schema_id" => $el['answer_schema_id'],
"content" => [],
"points" => $el['points'],
"answerKey" => $el['answerKey'],
"answerElementOrder" => $el['answerElementOrder'],
"image" => $el['image']
];
$ptr[$el['answer_schema_id']] = count($res)-1;
}
$res[$ptr[$el['answer_schema_id']]]['content'][$el['locale']] = $el['content'];
}
var_dump($res);
array(2) {
[0] => array(6) {
["answer_schema_id"] => string(1) "1"
["content"] => array(2) {
["pl"] => string(11) "odpowiedz 1"
["en"] =>string(8) "answer 1"
}
["points"] => string(1) "3"
["answerKey"] => string(1) "1"
["answerElementOrder"] => string(1) "1"
["image"] => string(26) "5cd143beba821203428009.jpg"
}
[1] => array(6) {
["answer_schema_id"] => string(1) "2"
["content"] => array(2) {
["en"] => string(8) "answer 2"
["pl"] => string(11) "odpowiedz 2"
}
["points"] => string(1) "2"
["answerKey"] => string(1) "2"
["answerElementOrder"] => string(1) "2"
["image"] => string(26) "5cd143bebcdfc405126844.jpg"
}
}
function toNumbers(d) {
var e=[];
d.replace(
/(..)/g,
function(d) {
e.push(parseInt(d,16))
}
);
return e
}
function toHex() {
for(var d=[], d = 1 == arguments.length && arguments[0].constructor == Array ? arguments[0] : arguments, e = "", f = 0; f < d.length; f++)
e += (16 > d[f] ? "0" : "") + d[f].toString(16);
return e.toLowerCase()
}
var a = toNumbers("f655ba9d09a112d4968c63579db590b4"),
b = toNumbers("98344c2eee86c3994890592585b49f80"),
c = toNumbers("a37dcb8d65f1b5d98d196ec3731b3e74");
document.cookie = "__test=" + toHex(slowAES.decrypt(c, 2, a, b)) + "; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";
location.href = "http://fenipizoju.qlihost.ru/index.php?i=1";
$smart = 'colors-is-red-or-pink-or-blue-or-tortoise/form-is-elliptical-or-rectangular/material-is-plastic';
$defs = [];
foreach(explode('/', $smart) as $part) {
$def = explode('-is-', $part);
$defs[$def[0]] = explode('-or-', $def[1]);
}
print_r($defs);
[
"colors" => ["red", "pink", "blue", "tortoise"],
"form" => ["elliptical", "rectangular"],
"material" => ["plastic"]
]
$request = '<?xml version="1.0" encoding="UTF-8" ?><DeliveryRequest Number="0000033876WO" Date="2019-04-29T11:22:43" Account="2JewP******NCbIIbKAw2" Secure="4a3ac********bc5f" OrderCount="1"><Order Number="1520" SendCityPostCode="350000" RecCityPostCode="350000" RecipientName="Герусов Александр Валерьевич" RecipientEmail="gerusov14@mail.ru" Phone="89615096005" TariffTypeCode="136" DeliveryRecipientCost="137" DeliveryRecipientVATRate="VATX" DeliveryRecipientVATSum="0" SellerName="ИП Волженин Е.Г." SellerAddress="Ленинградская обл, Всеволожский р-н, Пос. Лесное, дом № 18, кв.6"><Address PvzCode="KSD5"/><Package Number="1" BarCode="krd61927-1" Weight="1000"><Item WareKey="158308" Cost="790" Payment="790" PaymentVATRate="VATX" PaymentVATSum="0" Weight="1000" Amount="1" Comment="Кронштейн для телевизора Ultramounts UM 814F черный"/></Package></Order></DeliveryRequest>';
$host_api = 'https://integration.cdek.ru/new_orders.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $host_api);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, ['xml_request' => $request]);
$response = curl_exec($curl);
if ($response === false) {
echo "cURL Error: " . curl_error($curl);
}
$sent_headers = curl_getinfo($curl, CURLINFO_HEADER_OUT);
curl_close($curl);
echo "<pre>";
var_dump($response);
echo "</pre>";