1. PHP / Говнокод #28108

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    <?php
    public function submit()
    {
    	$requestUri = 'http://127.0.0.1:8000/test/hs/Services/GetShedule';
    	$response = $this->doPostCall($requestUri . '?' . $this->prepareParams(), null);
    	$temp_str = json_encode(mb_convert_encoding($response, 'UTF-8'));
    	$temp_str = str_replace('\ufeff', '', $temp_str);
    	$temp_str = str_replace('\r', '', $temp_str);
    	$temp_str = str_replace('\n', '', $temp_str);
    	$temp_str = str_replace('\"', '"', $temp_str);
    	$temp_str = mb_strcut($temp_str, 1, -1);
    	$temp_arr = json_decode($temp_str, true);
    
    	$post_main_data = [];
    	$post_sub_data = [];
    	
    	foreach($temp_arr as $main_unit_key => $main_unit_value) {
    		foreach($main_unit_value as $main_unit_feature_key => $main_unit_feature_value) {
    			foreach ($main_unit_feature_value as $sub_unit_key => $sub_unit_value) {
    				foreach($sub_unit_value as $sub_unit_feature_key => $sub_unit_feature_value) {
    					unset($sub_unit_value['Расписание']);
    					$post_sub_data[$main_unit_key][$main_unit_feature_key][$sub_unit_key] = $sub_unit_value;
    				}
    			}
    		}
    	}
    
    	$raw_data = $temp_arr;
    	$filter = array('Посты');
    	$raw_data_length = count($raw_data);
    	for ($row = 0; $row < $raw_data_length; $row++) {
    		$post_main_data[] = array_diff_key($raw_data[$row], array_flip($filter));
    	}
    
    	foreach($post_main_data as $pmd_key => $pmd_value) {
    		$post_main_data[$pmd_key][key($post_sub_data[$pmd_key])] = array_values(array_values($post_sub_data[$pmd_key])[0]);
    	}
    
    	header_remove();
    	header("Content-Type: application/json");
    	http_response_code(200);
    	exit();
    }
    ?>

    Запостил: JohnDoe, 04 Апреля 2022

    Комментарии (1) RSS

    Добавить комментарий