3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$str = file_get_contents("file.csv"); $str = "sku,is_in_stock,warehouse_3,warehouse_4 AP-STYLUS,0,20,5 RC-3049,0,0,0 NFNC-FLAT-CAP,0,20,20 NFNC-HOOD14-ZIP-S,1,0,5"; $arr = explode("\n", $str); $result = array(); Foreach($arr as $line){ $linearr = explode(",", $line); If(is_numeric($linearr[2])){ if($linearr[2]+$linearr[3]>=1){ $linearr[1]="1"; $line = implode("," , $linearr); }else{ $linearr[1]="0"; $line = implode("," , $linearr); } } $result[]=$line; } $newstr = implode("\n", $result); //put_file_contents("file.csv", $newstr); Echo $newstr;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 42
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 39
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 32
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 39
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/63vmh
function name:  (null)
number of ops:  50
compiled vars:  !0 = $str, !1 = $arr, !2 = $result, !3 = $line, !4 = $linearr, !5 = $newstr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'sku%2Cis_in_stock%2Cwarehouse_3%2Cwarehouse_4%0AAP-STYLUS%2C0%2C20%2C5%0ARC-3049%2C0%2C0%2C0%0ANFNC-FLAT-CAP%2C0%2C20%2C20%0ANFNC-HOOD14-ZIP-S%2C1%2C0%2C5'
   10     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   12     6        ASSIGN                                                   !2, <array>
   14     7      > FE_RESET_R                                       $10     !1, ->42
          8    > > FE_FETCH_R                                               $10, !3, ->42
   15     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%2C'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !4, $11
   16    14        INIT_FCALL                                               'is_numeric'
         15        FETCH_DIM_R                                      ~13     !4, 2
         16        SEND_VAL                                                 ~13
         17        DO_ICALL                                         $14     
         18      > JMPZ                                                     $14, ->39
   17    19    >   FETCH_DIM_R                                      ~15     !4, 2
         20        FETCH_DIM_R                                      ~16     !4, 3
         21        ADD                                              ~17     ~15, ~16
         22        IS_SMALLER_OR_EQUAL                                      1, ~17
         23      > JMPZ                                                     ~18, ->32
   18    24    >   ASSIGN_DIM                                               !4, 1
         25        OP_DATA                                                  '1'
   19    26        INIT_FCALL                                               'implode'
         27        SEND_VAL                                                 '%2C'
         28        SEND_VAR                                                 !4
         29        DO_ICALL                                         $20     
         30        ASSIGN                                                   !3, $20
   17    31      > JMP                                                      ->39
   21    32    >   ASSIGN_DIM                                               !4, 1
         33        OP_DATA                                                  '0'
   22    34        INIT_FCALL                                               'implode'
         35        SEND_VAL                                                 '%2C'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                         $23     
         38        ASSIGN                                                   !3, $23
   25    39    >   ASSIGN_DIM                                               !2
         40        OP_DATA                                                  !3
   14    41      > JMP                                                      ->8
         42    >   FE_FREE                                                  $10
   29    43        INIT_FCALL                                               'implode'
         44        SEND_VAL                                                 '%0A'
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                         $26     
         47        ASSIGN                                                   !5, $26
   32    48        ECHO                                                     !5
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.68 ms | 1466 KiB | 16 Q