3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <calender> <item> <date>20140113</date> <title>My Birthday</title> </item> <item> <date>20140112</date> <title>test</title> </item> <item> <date>20130114</date> <title>test</title> </item> </calender> XML ); $arr=array(); foreach($xml->item as $aTask) { $arr[]=$aTask; } //print_r($arr); usort($arr,function($a,$b){ return strtotime($a->date)-strtotime($b->date); }); //print_r($arr); $xml=simplexml_load_string(<<<XML <?xml version="1.0"?> <calender> </calender> XML ); foreach($arr as $aTask) { $tTask=$xml->addChild($aTask->getName()); $tTask->addChild($aTask->date->getName(),(string)$aTask->date); $tTask->addChild($aTask->title->getName(),(string)$aTask->title); } echo $xml->asXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 48
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 48
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 11
filename:       /in/fNOB1
function name:  (null)
number of ops:  53
compiled vars:  !0 = $xml, !1 = $arr, !2 = $aTask, !3 = $tTask
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'simplexml_load_string'
    3     1        SEND_VAL                                                 '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Ccalender%3E%0A%0A%3Citem%3E%0A%3Cdate%3E20140113%3C%2Fdate%3E%0A%3Ctitle%3EMy+Birthday%3C%2Ftitle%3E%0A%3C%2Fitem%3E%0A%0A%3Citem%3E%0A%3Cdate%3E20140112%3C%2Fdate%3E%0A%3Ctitle%3Etest%3C%2Ftitle%3E%0A%3C%2Fitem%3E%0A%0A%3Citem%3E%0A%3Cdate%3E20130114%3C%2Fdate%3E%0A%3Ctitle%3Etest%3C%2Ftitle%3E%0A%3C%2Fitem%3E%0A%0A%0A%3C%2Fcalender%3E'
          2        DO_ICALL                                         $4      
    2     3        ASSIGN                                                   !0, $4
   25     4        ASSIGN                                                   !1, <array>
   26     5        FETCH_OBJ_R                                      ~7      !0, 'item'
          6      > FE_RESET_R                                       $8      ~7, ->11
          7    > > FE_FETCH_R                                               $8, !2, ->11
   28     8    >   ASSIGN_DIM                                               !1
          9        OP_DATA                                                  !2
   26    10      > JMP                                                      ->7
         11    >   FE_FREE                                                  $8
   31    12        INIT_FCALL                                               'usort'
         13        SEND_REF                                                 !1
         14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfNOB1%3A31%240'
   33    15        SEND_VAL                                                 ~10
         16        DO_ICALL                                                 
   35    17        INIT_FCALL                                               'simplexml_load_string'
   36    18        SEND_VAL                                                 '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Ccalender%3E%0A%3C%2Fcalender%3E'
         19        DO_ICALL                                         $12     
   35    20        ASSIGN                                                   !0, $12
   41    21      > FE_RESET_R                                       $14     !1, ->48
         22    > > FE_FETCH_R                                               $14, !2, ->48
   43    23    >   INIT_METHOD_CALL                                         !0, 'addChild'
         24        INIT_METHOD_CALL                                         !2, 'getName'
         25        DO_FCALL                                      0  $15     
         26        SEND_VAR_NO_REF_EX                                       $15
         27        DO_FCALL                                      0  $16     
         28        ASSIGN                                                   !3, $16
   44    29        INIT_METHOD_CALL                                         !3, 'addChild'
         30        FETCH_OBJ_R                                      ~18     !2, 'date'
         31        INIT_METHOD_CALL                                         ~18, 'getName'
         32        DO_FCALL                                      0  $19     
         33        SEND_VAR_NO_REF_EX                                       $19
         34        FETCH_OBJ_R                                      ~20     !2, 'date'
         35        CAST                                          6  ~21     ~20
         36        SEND_VAL_EX                                              ~21
         37        DO_FCALL                                      0          
   45    38        INIT_METHOD_CALL                                         !3, 'addChild'
         39        FETCH_OBJ_R                                      ~23     !2, 'title'
         40        INIT_METHOD_CALL                                         ~23, 'getName'
         41        DO_FCALL                                      0  $24     
         42        SEND_VAR_NO_REF_EX                                       $24
         43        FETCH_OBJ_R                                      ~25     !2, 'title'
         44        CAST                                          6  ~26     ~25
         45        SEND_VAL_EX                                              ~26
         46        DO_FCALL                                      0          
   41    47      > JMP                                                      ->22
         48    >   FE_FREE                                                  $14
   47    49        INIT_METHOD_CALL                                         !0, 'asXML'
         50        DO_FCALL                                      0  $28     
         51        ECHO                                                     $28
         52      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FfNOB1%3A31%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fNOB1
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        INIT_FCALL                                               'strtotime'
          3        FETCH_OBJ_R                                      ~2      !0, 'date'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        INIT_FCALL                                               'strtotime'
          7        FETCH_OBJ_R                                      ~4      !1, 'date'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                         $5      
         10        SUB                                              ~6      $3, $5
         11      > RETURN                                                   ~6
   33    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfNOB1%3A31%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.05 ms | 1400 KiB | 19 Q