@anonymous/

DeepWelltodoSequences

PHP (Legacy)

No description

fork
loading
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$room_details = array(
    (object)array(
                'id' => 4508,
                'api' => 'hotelbeds',
                'room_no' => 1,
                'room_type' => 'APARTMENT ONE BEDROOM',
                'meal_type' => 'ONE ROOM',
                'updated_on' => '2019-01-16 13:03:17'
        ),

    (object)array(
                'id' => 4509,
                'room_no' => 2,
                'room_type' => 'APARTMENT TWO BEDROOM',
                'meal_type' => 'TWO ROOMS',
                'updated_on' => '2019-01-16 13:03:09'
        ),

    (object)array(
                'id' => 4510,
                'room_no' => 3,
                'room_type' => 'APARTMENT ONE BEDROOM',
                'meal_type' => 'TWO ROOMS',
                'updated_on' => '2019-01-16 13:03:38'
        ),
);

$countedValues = array_count_values(array_map(function($x){return $x->meal_type;},$room_details));
//Build strings from value and display them.
foreach( $countedValues as $mealtype=>$count ){
        echo $count . ' x ' . $mealtype . '<br />';
}
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7