rrre - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of rrre.php
- <?php
- $str = '[
- {"Наименование": "Дверь-купе Зеркало 600", "Вес":17.500, "Объем":0.056, "Высота":2.090, "Ширина":0.600,"Глубина":0.045},
- {"Наименование": "Дверь-купе Зеркало 600", "Вес":17.500, "Объем":0.056, "Высота":2.090, "Ширина":0.600,"Глубина":0.045},
- {"Наименование": "Комплект П-2 1200", "Вес":41.500, "Объем":0.089, "Высота":1.210, "Ширина":0.610,"Глубина":0.120},
- {"Наименование": "Комплект стоевых", "Вес":39.000, "Объем":0.071, "Высота":2.110, "Ширина":0.610,"Глубина":0.055}
- ]';
- $digit["Height"]["dig"] = array();
- $digit["Height"]["summ"] = 0;
- $digit["Width"]["dig"] = array();
- $digit["Width"]["summ"] = 0;
- $digit["Depth"]["dig"] = array();
- $digit["Depth"]["summ"] = 0;
- $digit["Mass"]["dig"] = array();
- $digit["Mass"]["summ"] = 0;
- //var_dump ($digit);
- preg_match_all('/\{(.*?)\}/',$str,$out, PREG_PATTERN_ORDER);
- foreach ($out[0] as $key => $value)
- {
- $line = json_decode($value,true,JSON_UNESCAPED_UNICODE);
- $digit["Height"]["dig"][$key] = $line['Высота'];
- $digit["Height"]["summ"] += $line['Высота'];
- $digit["Width"]["dig"][$key] = $line['Ширина'];
- $digit["Width"]["summ"] += $line['Ширина'];
- $digit["Depth"]["dig"][$key] = $line['Глубина'];
- $digit["Depth"]["summ"] += $line['Глубина'];
- $digit["Mass"]["dig"][$key] = $line['Вес'];
- $digit["Mass"]["summ"] += $line['Вес'];
- }
- print_r($digit);
- ?>
File Description
- rrre
- PHP Code
- 31 Mar-2021
- 1.58 Kb
You can Share it:
Latest PHP Pastes