3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<'EOF' text 16.11 19.22 21.33 text 17.11 23.22 25.33 27.55 text 18.11 26.22 EOF; echo 'Если не завязываться на количестве пробелов: ', PHP_EOL; $res = []; $lines = preg_split('#[\n\r]+#', trim($str)); foreach ($lines as $line) { $prices = preg_split('#\s+#', $line); $key = array_shift($prices); $res[] = ['key' => $key, 'prices' => $prices]; } echo json_encode($res), PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/Lt08M
function name:  (null)
number of ops:  35
compiled vars:  !0 = $str, !1 = $res, !2 = $lines, !3 = $line, !4 = $prices, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'text++++16.11+19.22++++++21.33%0Atext+++17.11+23.22+25.33+27.55%0Atext++++18.11++++++++++++26.22'
    9     1        ECHO                                                     '%D0%95%D1%81%D0%BB%D0%B8+%D0%BD%D0%B5+%D0%B7%D0%B0%D0%B2%D1%8F%D0%B7%D1%8B%D0%B2%D0%B0%D1%82%D1%8C%D1%81%D1%8F+%D0%BD%D0%B0+%D0%BA%D0%BE%D0%BB%D0%B8%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%B5+%D0%BF%D1%80%D0%BE%D0%B1%D0%B5%D0%BB%D0%BE%D0%B2%3A+'
          2        ECHO                                                     '%0A'
   10     3        ASSIGN                                                   !1, <array>
   11     4        INIT_FCALL                                               'preg_split'
          5        SEND_VAL                                                 '%23%5B%5Cn%5Cr%5D%2B%23'
          6        INIT_FCALL                                               'trim'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $8      
          9        SEND_VAR                                                 $8
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !2, $9
   12    12      > FE_RESET_R                                       $11     !2, ->28
         13    > > FE_FETCH_R                                               $11, !3, ->28
   13    14    >   INIT_FCALL                                               'preg_split'
         15        SEND_VAL                                                 '%23%5Cs%2B%23'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !4, $12
   14    19        INIT_FCALL                                               'array_shift'
         20        SEND_REF                                                 !4
         21        DO_ICALL                                         $14     
         22        ASSIGN                                                   !5, $14
   15    23        INIT_ARRAY                                       ~17     !5, 'key'
         24        ADD_ARRAY_ELEMENT                                ~17     !4, 'prices'
         25        ASSIGN_DIM                                               !1
         26        OP_DATA                                                  ~17
   12    27      > JMP                                                      ->13
         28    >   FE_FREE                                                  $11
   17    29        INIT_FCALL                                               'json_encode'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $18     
         32        ECHO                                                     $18
         33        ECHO                                                     '%0A'
   18    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.19 ms | 1388 KiB | 21 Q