3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlns_siri = 'http://www.siri.org.uk/siri'; $searchForID = '2755'; $reader = new XMLReader(); $reader->open('data:text/xml;base64,'.base64_encode(getXMLString())); $document = new DOMDocument(); $xpath = new DOMXpath($document); // register an alias for the siri namespace $xpath->registerNamespace('siri', $xmlns_siri); // look for the first "item" element node while ( $reader->read() && ( $reader->localName !== 'EstimatedVehicleJourney' || $reader->namespaceURI !== $xmlns_siri ) ) { continue; } // iterate "item" sibling elements while ($reader->localName === 'EstimatedVehicleJourney') { // validate the namespace of the node if ($reader->namespaceURI === $xmlns_siri) { // expand into DOM $item = $reader->expand($document); // if the node has a child "VehicleRef" with the searched contents // note the use of the registered namespace alias if ($xpath->evaluate("count(self::*[siri:VehicleRef = '$searchForID']) > 0", $item)) { var_dump( [ // fetch node text content as string 'name' => $xpath->evaluate('string(siri:OriginName)', $item), // fetch list of "call" elements and map them 'calls' => array_map( function(DOMElement $call) use ($xpath) { return [ 'name' => $xpath->evaluate('string(siri:StopPointName)', $call), 'reference' => $xpath->evaluate('string(siri:StopPointRef)', $call) ]; }, iterator_to_array( $xpath->evaluate('siri:RecordedCalls/siri:RecordedCall', $item) ) ) ] ); } } $reader->next('EstimatedVehicleJourney'); } $reader->close(); function getXMLString() { return <<<'XML' <Siri xmlns="http://www.siri.org.uk/siri"> <ServiceDelivery> <ResponseTimestamp>2021-09-02T18:36:10+02:00</ResponseTimestamp> <Status>true</Status> <MoreData>false</MoreData> <EstimatedTimetableDelivery> <ResponseTimestamp>2021-09-02T18:36:10+02:00</ResponseTimestamp> <ValidUntil>2021-09-02T19:36:10+02:00</ValidUntil> <EstimatedJourneyVersionFrame> <RecordedAtTime>2021-09-02T18:36:10+02:00</RecordedAtTime> <EstimatedVehicleJourney> <LineRef>L2</LineRef> <DirectionRef>SKI</DirectionRef> <DatedVehicleJourneyRef>2755:2021-09-02</DatedVehicleJourneyRef> <VehicleMode>rail</VehicleMode> <OriginRef>STB</OriginRef> <OriginName>Stabekk</OriginName> <DestinationRef>SKI</DestinationRef> <DestinationName>Ski</DestinationName> <OperatorRef>VY</OperatorRef> <ProductCategoryRef>Lt</ProductCategoryRef> <ServiceFeatureRef>passengerTrain</ServiceFeatureRef> <VehicleRef>2755</VehicleRef> <RecordedCalls> <RecordedCall> <StopPointRef>STB</StopPointRef> <StopPointName>Stabekk</StopPointName> <AimedDepartureTime>2021-09-02T18:19:00+02:00</AimedDepartureTime> <DeparturePlatformName>2</DeparturePlatformName> <ActualDepartureTime>2021-09-02T18:19:13+02:00</ActualDepartureTime> </RecordedCall> <RecordedCall> <StopPointRef>STB</StopPointRef> <StopPointName>Stabekk</StopPointName> <AimedDepartureTime>2021-09-02T18:19:00+02:00</AimedDepartureTime> <DeparturePlatformName>2</DeparturePlatformName> <ActualDepartureTime>2021-09-02T18:19:13+02:00</ActualDepartureTime> </RecordedCall> </RecordedCalls> <EstimatedCalls> <EstimatedCall> <StopPointRef>SKI</StopPointRef> <StopPointName>Ski</StopPointName> <RequestStop>false</RequestStop> <AimedArrivalTime>2021-09-02T18:39:00+02:00</AimedArrivalTime> <ExpectedArrivalTime>2021-09-02T18:40:42+02:00</ExpectedArrivalTime> <ArrivalStatus>onTime</ArrivalStatus> <ArrivalPlatformName>1</ArrivalPlatformName> <ArrivalBoardingActivity>alighting</ArrivalBoardingActivity> </EstimatedCall> <EstimatedCall> <StopPointRef>SKI</StopPointRef> <StopPointName>Ski</StopPointName> <RequestStop>false</RequestStop> <AimedArrivalTime>2021-09-02T18:39:00+02:00</AimedArrivalTime> <ExpectedArrivalTime>2021-09-02T18:40:42+02:00</ExpectedArrivalTime> <ArrivalStatus>onTime</ArrivalStatus> <ArrivalPlatformName>1</ArrivalPlatformName> <ArrivalBoardingActivity>alighting</ArrivalBoardingActivity> </EstimatedCall> </EstimatedCalls> <IsCompleteStopSequence>true</IsCompleteStopSequence> </EstimatedVehicleJourney> <EstimatedVehicleJourney> <LineRef>L2</LineRef> <DirectionRef>SKI</DirectionRef> <DatedVehicleJourneyRef>2755:2021-09-02</DatedVehicleJourneyRef> <VehicleMode>rail</VehicleMode> <OriginRef>STB</OriginRef> <OriginName>Stabekk</OriginName> <DestinationRef>SKI</DestinationRef> <DestinationName>Ski</DestinationName> <OperatorRef>VY</OperatorRef> <ProductCategoryRef>Lt</ProductCategoryRef> <ServiceFeatureRef>passengerTrain</ServiceFeatureRef> <VehicleRef>2755</VehicleRef> <RecordedCalls> <RecordedCall> <StopPointRef>STB</StopPointRef> <StopPointName>Stabekk</StopPointName> <AimedDepartureTime>2021-09-02T18:19:00+02:00</AimedDepartureTime> <DeparturePlatformName>2</DeparturePlatformName> <ActualDepartureTime>2021-09-02T18:19:13+02:00</ActualDepartureTime> </RecordedCall> <RecordedCall> <StopPointRef>STB</StopPointRef> <StopPointName>Stabekk</StopPointName> <AimedDepartureTime>2021-09-02T18:19:00+02:00</AimedDepartureTime> <DeparturePlatformName>2</DeparturePlatformName> <ActualDepartureTime>2021-09-02T18:19:13+02:00</ActualDepartureTime> </RecordedCall> </RecordedCalls> <EstimatedCalls> <EstimatedCall> <StopPointRef>SKI</StopPointRef> <StopPointName>Ski</StopPointName> <RequestStop>false</RequestStop> <AimedArrivalTime>2021-09-02T18:39:00+02:00</AimedArrivalTime> <ExpectedArrivalTime>2021-09-02T18:40:42+02:00</ExpectedArrivalTime> <ArrivalStatus>onTime</ArrivalStatus> <ArrivalPlatformName>1</ArrivalPlatformName> <ArrivalBoardingActivity>alighting</ArrivalBoardingActivity> </EstimatedCall> <EstimatedCall> <StopPointRef>SKI</StopPointRef> <StopPointName>Ski</StopPointName> <RequestStop>false</RequestStop> <AimedArrivalTime>2021-09-02T18:39:00+02:00</AimedArrivalTime> <ExpectedArrivalTime>2021-09-02T18:40:42+02:00</ExpectedArrivalTime> <ArrivalStatus>onTime</ArrivalStatus> <ArrivalPlatformName>1</ArrivalPlatformName> <ArrivalBoardingActivity>alighting</ArrivalBoardingActivity> </EstimatedCall> </EstimatedCalls> <IsCompleteStopSequence>true</IsCompleteStopSequence> </EstimatedVehicleJourney> </EstimatedJourneyVersionFrame> </EstimatedTimetableDelivery> </ServiceDelivery> </Siri> XML; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.10.0080.01018.99
8.5.00.0110.01120.54
8.4.160.0120.01024.30
8.4.150.0020.00114.05
8.4.140.0130.00918.44
8.4.130.0120.00920.08
8.4.120.0130.00821.25
8.4.110.0120.01019.41
8.4.100.0140.00925.02
8.4.90.0100.00919.45
8.4.80.0060.00720.14
8.4.70.0090.00518.61
8.4.60.0090.00919.40
8.4.50.0110.01019.27
8.4.40.0090.00618.31
8.4.30.0090.01220.76
8.4.20.0060.00320.06
8.4.10.0000.01019.95
8.3.280.0020.00114.05
8.3.270.0130.00917.23
8.3.260.0080.01117.23
8.3.250.0120.00817.71
8.3.240.0050.00617.21
8.3.230.0160.00717.02
8.3.220.0130.00717.91
8.3.210.0090.01018.97
8.3.200.0050.00417.25
8.3.190.0050.00417.97
8.3.180.0050.00517.16
8.3.170.0160.00319.43
8.3.160.0130.00720.77
8.3.150.0100.01017.79
8.3.140.0060.00319.14
8.3.130.0060.00617.02
8.3.120.0100.01019.52
8.3.110.0070.01317.29
8.3.100.0090.00017.41
8.3.90.0080.00026.77
8.3.80.0080.00317.00
8.3.70.0130.01018.81
8.3.60.0160.00617.25
8.3.50.0080.00818.65
8.3.40.0130.00324.20
8.3.30.0100.00719.39
8.3.20.0050.00324.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.290.0140.00621.09
8.2.280.0100.00918.75
8.2.270.0100.01017.77
8.2.260.0000.00821.47
8.2.250.0070.00417.09
8.2.240.0080.00018.92
8.2.230.0100.01020.94
8.2.220.0040.00424.06
8.2.210.0130.00726.77
8.2.200.0090.00017.13
8.2.190.0150.00717.13
8.2.180.0060.00925.92
8.2.170.0040.01119.44
8.2.160.0100.01022.96
8.2.150.0050.00325.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0110.00726.16
8.2.110.0030.00621.05
8.2.100.0100.00021.06
8.1.330.0100.00922.92
8.1.320.0150.00716.79
8.1.310.0190.00017.30
8.1.300.0040.01119.09
8.1.290.0070.00330.84
8.1.280.0120.00325.92
8.1.270.0080.00024.34
8.1.260.0030.00626.35
8.1.250.0030.00628.09
8.1.240.0040.00718.96
8.1.230.0040.00422.70
8.0.100.0010.00717.49

preferences:
34.49 ms | 403 KiB | 5 Q