3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ [ 'lang' => 'de', 'value' => "text_1_en_Text i need", 'id' => 2365 ], [ 'lang' => 'en', 'value' => "something i dont need", 'id' => 2365 ] ]; $needle = 'text_1_en_'; var_export( array_filter( $array, fn($row) => str_starts_with($row['value'], $needle) ) ); echo "\n---\n"; $result = []; foreach ($array as $row) { if (str_starts_with($row['value'], $needle)) { $result = $row; break; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
Branch analysis from position: 21
filename:       /in/FdEBu
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array, !1 = $needle, !2 = $result, !3 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   16     1        ASSIGN                                                       !1, 'text_1_en_'
   17     2        INIT_FCALL                                                   'var_export'
   18     3        INIT_FCALL                                                   'array_filter'
   19     4        SEND_VAR                                                     !0
   20     5        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
          6        BIND_LEXICAL                                                 ~6, !1
   21     7        SEND_VAL                                                     ~6
   18     8        DO_ICALL                                             $7      
   21     9        SEND_VAR                                                     $7
   17    10        DO_ICALL                                                     
   24    11        ECHO                                                         '%0A---%0A'
   26    12        ASSIGN                                                       !2, <array>
   27    13      > FE_RESET_R                                           $10     !0, ->21
         14    > > FE_FETCH_R                                                   $10, !3, ->21
   28    15    >   FETCH_DIM_R                                          ~11     !3, 'value'
         16        FRAMELESS_ICALL_2                str_starts_with      ~12     ~11, !1
         17      > JMPZ                                                         ~12, ->20
   29    18    >   ASSIGN                                                       !2, !3
   30    19      > JMP                                                          ->21
   27    20    > > JMP                                                          ->14
         21    >   FE_FREE                                                      $10
   33    22        INIT_FCALL                                                   'var_export'
         23        SEND_VAR                                                     !2
         24        DO_ICALL                                                     
         25      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FdEBu
function name:  {closure:/in/FdEBu:20}
number of ops:  6
compiled vars:  !0 = $row, !1 = $needle
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        FETCH_DIM_R                                          ~2      !0, 'value'
          3        FRAMELESS_ICALL_2                str_starts_with      ~3      ~2, !1
          4      > RETURN                                                       ~3
   21     5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.22 ms | 1921 KiB | 15 Q