3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA Main{ NetworkAccess 1; MaxCPE 6; MaxClassifiers 20; GlobalPrivacyEnable 1; BaselinePrivacy{ AuthTimeout 10; ReAuthTimeout 10; AuthGraceTime 600; OperTimeout 10; ReKeyTimeout 10; TEKGraceTime 600; AuthRejectTimeout 60; SAMapWaitTimeout 1; SAMapMaxRetries 4; } UsServiceFlow{ UsServiceFlowRef 1; QosParamSetType 7; TrafficPriority 2; MaxRateSustained 1000000; SchedulingType 2; MaxTrafficBurst 8000; MaxConcatenatedBurst 8000; } DsServiceFlow{ DsServiceFlowRef 101; QosParamSetType 7; TrafficPriority 2; MaxRateSustained 10000000; } } DATA; function processItems($items, &$current, &$parent) { $item = trim(array_shift($items)); if ($item) { if (substr($item, -1) === '{') { $key = rtrim($item, '{'); $current[$key] = []; processItems($items, $current[$key], $parent); return; } if (trim($item) === '}') { processItems($items, $parent, $parent); return; } $parts = explode(' ', $item); $current[$parts[0]] = rtrim($parts[1], ';'); processItems($items, $current, $parent); } } $curr = []; processItems(explode("\n", $data), $curr, $curr); print_r($curr);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /in/2XmSV on line 39 Array ( [Main] => Array ( [NetworkAccess] => 1 [MaxCPE] => 6 [MaxClassifiers] => 20 [GlobalPrivacyEnable] => 1 [BaselinePrivacy] => Array ( [AuthTimeout] => 10 [ReAuthTimeout] => 10 [AuthGraceTime] => 600 [OperTimeout] => 10 [ReKeyTimeout] => 10 [TEKGraceTime] => 600 [AuthRejectTimeout] => 60 [SAMapWaitTimeout] => 1 [SAMapMaxRetries] => 4 ) ) [UsServiceFlow] => Array ( [UsServiceFlowRef] => 1 [QosParamSetType] => 7 [TrafficPriority] => 2 [MaxRateSustained] => 1000000 [SchedulingType] => 2 [MaxTrafficBurst] => 8000 [MaxConcatenatedBurst] => 8000 ) [DsServiceFlow] => Array ( [DsServiceFlowRef] => 101 [QosParamSetType] => 7 [TrafficPriority] => 2 [MaxRateSustained] => 10000000 ) )
Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Array ( [Main] => Array ( [NetworkAccess] => 1 [MaxCPE] => 6 [MaxClassifiers] => 20 [GlobalPrivacyEnable] => 1 [BaselinePrivacy] => Array ( [AuthTimeout] => 10 [ReAuthTimeout] => 10 [AuthGraceTime] => 600 [OperTimeout] => 10 [ReKeyTimeout] => 10 [TEKGraceTime] => 600 [AuthRejectTimeout] => 60 [SAMapWaitTimeout] => 1 [SAMapMaxRetries] => 4 ) ) [UsServiceFlow] => Array ( [UsServiceFlowRef] => 1 [QosParamSetType] => 7 [TrafficPriority] => 2 [MaxRateSustained] => 1000000 [SchedulingType] => 2 [MaxTrafficBurst] => 8000 [MaxConcatenatedBurst] => 8000 ) [DsServiceFlow] => Array ( [DsServiceFlowRef] => 101 [QosParamSetType] => 7 [TrafficPriority] => 2 [MaxRateSustained] => 10000000 ) )

preferences:
139.33 ms | 413 KiB | 5 Q