3v4l.org

run code in 300+ PHP versions simultaneously
<?php $database = 'id|name_sname|identity|address|region|hours|destination|price; -------------------------------------------------------------------- 1|Test Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100; 2|Jhon Doe|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100; 3|Himel Rana|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100; 4|Ezra Mod|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100; 5|Keven Korp|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100; 6|Tamim Iqbal|123456789|husi, stanilesti, vaslui|HUSI - IASI|20:00|HUSI|100;'; //$data = file_get_contents("database.txt"); //read the file $rows = explode("\n", $database); //create array separate by new line $rows = array_map("trim", $rows); // for removing any unwanted space $rowCount = count($rows); // Count your database rows function CountCol($data){ $col = explode("|", $data); return count($col); } // Creating array from our text database // in our database first two rows are not needed so I am skipig this // by using i = 2 // and $rowCount -1 because of our array start from 0 but count start from 1 // adding $id[$i-2] and like other because of we have started our first loop from 2 and I want to // create my new array starting from 0 . for ($i=2; $i <$rowCount-1 ; $i++) { for ($j=0; $j < CountCol($rows[$i]) ; $j++) { $column = explode("|", $rows[$i]); $id[$i-2] = $column[0]; $name_sname[$i-2] = $column[1]; $identity[$i-2] = $column[2]; $address[$i-2] = $column[3]; $region[$i-2] = $column[4]; $hours[$i-2] = $column[5]; $destination[$i-2] = $column[6]; $price[$i-2] = $column[7]; } } // let's print our data // I am using 3 here because of we have no need first 2 rows and our array start from 0 for ($i=0; $i < $rowCount-3 ; $i++) { echo "ID: ".$id[$i] ."\r\n"; echo "name_sname: ".$name_sname[$i]."\r\n"; echo "identity: ".$identity[$i] ."\r\n"; echo "address: ".$address[$i] ."\r\n"; echo "region: ".$region[$i] ."\r\n"; echo "hours: ".$hours[$i] ."\r\n"; echo "destination: ".$destination[$i] ."\r\n"; echo "price: ".$price[$i] ."\r\n"; } // // get it like below echo "printing information using id number \r\n"; echo $name_sname[0]; // here 0 is row number or id number echo "\r\n"; echo $name_sname[1];// here 1 is row number or id number echo "\r\n"; echo $id[0]; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 15
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 101
Branch analysis from position: 101
2 jumps found. (Code = 44) Position 1 = 104, Position 2 = 68
Branch analysis from position: 104
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 104, Position 2 = 68
Branch analysis from position: 104
Branch analysis from position: 68
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 17
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 15
Branch analysis from position: 66
Branch analysis from position: 15
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 17
Branch analysis from position: 62
Branch analysis from position: 17
filename:       /in/Xhr68
function name:  (null)
number of ops:  114
compiled vars:  !0 = $database, !1 = $rows, !2 = $rowCount, !3 = $i, !4 = $j, !5 = $column, !6 = $id, !7 = $name_sname, !8 = $identity, !9 = $address, !10 = $region, !11 = $hours, !12 = $destination, !13 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'id%7Cname_sname%7Cidentity%7Caddress%7Cregion%7Chours%7Cdestination%7Cprice%3B%0A--------------------------------------------------------------------%0A1%7CTest+Mod%7C123456789%7Chusi%2C+stanilesti%2C+vaslui%7CHUSI+-+IASI%7C20%3A00%7CHUSI%7C100%3B%0A2%7CJhon+Doe%7C123456789%7Chusi%2C+stanilesti%2C+vaslui%7CHUSI+-+IASI%7C20%3A00%7CHUSI%7C100%3B%0A3%7CHimel+Rana%7C123456789%7Chusi%2C+stanilesti%2C+vaslui%7CHUSI+-+IASI%7C20%3A00%7CHUSI%7C100%3B%0A4%7CEzra+Mod%7C123456789%7Chusi%2C+stanilesti%2C+vaslui%7CHUSI+-+IASI%7C20%3A00%7CHUSI%7C100%3B%0A5%7CKeven+Korp%7C123456789%7Chusi%2C+stanilesti%2C+vaslui%7CHUSI+-+IASI%7C20%3A00%7CHUSI%7C100%3B%0A6%7CTamim+Iqbal%7C123456789%7Chusi%2C+stanilesti%2C+vaslui%7CHUSI+-+IASI%7C20%3A00%7CHUSI%7C100%3B'
   13     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $15     
          5        ASSIGN                                                   !1, $15
   14     6        INIT_FCALL                                               'array_map'
          7        SEND_VAL                                                 'trim'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $17     
         10        ASSIGN                                                   !1, $17
   15    11        COUNT                                            ~19     !1
         12        ASSIGN                                                   !2, ~19
   30    13        ASSIGN                                                   !3, 2
         14      > JMP                                                      ->63
   31    15    >   ASSIGN                                                   !4, 0
         16      > JMP                                                      ->56
   32    17    >   INIT_FCALL                                               'explode'
         18        SEND_VAL                                                 '%7C'
         19        FETCH_DIM_R                                      ~23     !1, !3
         20        SEND_VAL                                                 ~23
         21        DO_ICALL                                         $24     
         22        ASSIGN                                                   !5, $24
   34    23        SUB                                              ~26     !3, 2
         24        FETCH_DIM_R                                      ~28     !5, 0
         25        ASSIGN_DIM                                               !6, ~26
         26        OP_DATA                                                  ~28
   35    27        SUB                                              ~29     !3, 2
         28        FETCH_DIM_R                                      ~31     !5, 1
         29        ASSIGN_DIM                                               !7, ~29
         30        OP_DATA                                                  ~31
   36    31        SUB                                              ~32     !3, 2
         32        FETCH_DIM_R                                      ~34     !5, 2
         33        ASSIGN_DIM                                               !8, ~32
         34        OP_DATA                                                  ~34
   37    35        SUB                                              ~35     !3, 2
         36        FETCH_DIM_R                                      ~37     !5, 3
         37        ASSIGN_DIM                                               !9, ~35
         38        OP_DATA                                                  ~37
   38    39        SUB                                              ~38     !3, 2
         40        FETCH_DIM_R                                      ~40     !5, 4
         41        ASSIGN_DIM                                               !10, ~38
         42        OP_DATA                                                  ~40
   39    43        SUB                                              ~41     !3, 2
         44        FETCH_DIM_R                                      ~43     !5, 5
         45        ASSIGN_DIM                                               !11, ~41
         46        OP_DATA                                                  ~43
   40    47        SUB                                              ~44     !3, 2
         48        FETCH_DIM_R                                      ~46     !5, 6
         49        ASSIGN_DIM                                               !12, ~44
         50        OP_DATA                                                  ~46
   41    51        SUB                                              ~47     !3, 2
         52        FETCH_DIM_R                                      ~49     !5, 7
         53        ASSIGN_DIM                                               !13, ~47
         54        OP_DATA                                                  ~49
   31    55        PRE_INC                                                  !4
         56    >   INIT_FCALL                                               'countcol'
         57        FETCH_DIM_R                                      ~51     !1, !3
         58        SEND_VAL                                                 ~51
         59        DO_FCALL                                      0  $52     
         60        IS_SMALLER                                               !4, $52
         61      > JMPNZ                                                    ~53, ->17
   30    62    >   PRE_INC                                                  !3
         63    >   SUB                                              ~55     !2, 1
         64        IS_SMALLER                                               !3, ~55
         65      > JMPNZ                                                    ~56, ->15
   49    66    >   ASSIGN                                                   !3, 0
         67      > JMP                                                      ->101
   51    68    >   FETCH_DIM_R                                      ~58     !6, !3
         69        CONCAT                                           ~59     'ID%3A+', ~58
         70        CONCAT                                           ~60     ~59, '%0D%0A'
         71        ECHO                                                     ~60
   52    72        FETCH_DIM_R                                      ~61     !7, !3
         73        CONCAT                                           ~62     'name_sname%3A+', ~61
         74        CONCAT                                           ~63     ~62, '%0D%0A'
         75        ECHO                                                     ~63
   53    76        FETCH_DIM_R                                      ~64     !8, !3
         77        CONCAT                                           ~65     'identity%3A+', ~64
         78        CONCAT                                           ~66     ~65, '%0D%0A'
         79        ECHO                                                     ~66
   54    80        FETCH_DIM_R                                      ~67     !9, !3
         81        CONCAT                                           ~68     'address%3A+', ~67
         82        CONCAT                                           ~69     ~68, '%0D%0A'
         83        ECHO                                                     ~69
   55    84        FETCH_DIM_R                                      ~70     !10, !3
         85        CONCAT                                           ~71     'region%3A+', ~70
         86        CONCAT                                           ~72     ~71, '%0D%0A'
         87        ECHO                                                     ~72
   56    88        FETCH_DIM_R                                      ~73     !11, !3
         89        CONCAT                                           ~74     'hours%3A+', ~73
         90        CONCAT                                           ~75     ~74, '%0D%0A'
         91        ECHO                                                     ~75
   57    92        FETCH_DIM_R                                      ~76     !12, !3
         93        CONCAT                                           ~77     'destination%3A+', ~76
         94        CONCAT                                           ~78     ~77, '%0D%0A'
         95        ECHO                                                     ~78
   58    96        FETCH_DIM_R                                      ~79     !13, !3
         97        CONCAT                                           ~80     'price%3A+', ~79
         98        CONCAT                                           ~81     ~80, '%0D%0A'
         99        ECHO                                                     ~81
   49   100        PRE_INC                                                  !3
        101    >   SUB                                              ~83     !2, 3
        102        IS_SMALLER                                               !3, ~83
        103      > JMPNZ                                                    ~84, ->68
   65   104    >   ECHO                                                     'printing+information+using+id+number+%0D%0A'
   67   105        FETCH_DIM_R                                      ~85     !7, 0
        106        ECHO                                                     ~85
   68   107        ECHO                                                     '%0D%0A'
   69   108        FETCH_DIM_R                                      ~86     !7, 1
        109        ECHO                                                     ~86
   70   110        ECHO                                                     '%0D%0A'
   71   111        FETCH_DIM_R                                      ~87     !6, 0
        112        ECHO                                                     ~87
   73   113      > RETURN                                                   1

Function countcol:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Xhr68
function name:  CountCol
number of ops:  9
compiled vars:  !0 = $data, !1 = $col
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%7C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
   19     6        COUNT                                            ~4      !1
          7      > RETURN                                                   ~4
   21     8*     > RETURN                                                   null

End of function countcol

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.06 ms | 1415 KiB | 18 Q