3v4l.org

run code in 300+ PHP versions simultaneously
<?php // For the sake of the example, first I reconstructed your array: $ar1 = array("service" => 8000, "network" => "111.111.111"); $ar2 = array("service" => 9000, "network" => "222.222.222"); $ar3 = array("service" => 9500, "network" => "333.333.333"); $x = array("size" => 995, "data" => array($ar1,$ar2,$ar3)); $record = NULL; $bus = 9000; for($n = 0; $n < count($x["data"]); $n++){ $checkService = $x["data"][$n]; if($checkService["service"] == $bus){ $record = $checkService["network"]; } } if ($record) { // If record found: echo "Lookup Results for ".$bus.": ".$record; // Since we are searching for 8000 in this example, this should output -> Lookup Results for 8000: 111.111.111 } else { echo "Record not found"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 13
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 13
Branch analysis from position: 26
Branch analysis from position: 13
Branch analysis from position: 21
filename:       /in/BYDSj
function name:  (null)
number of ops:  34
compiled vars:  !0 = $ar1, !1 = $ar2, !2 = $ar3, !3 = $x, !4 = $record, !5 = $bus, !6 = $n, !7 = $checkService
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
    7     3        INIT_ARRAY                                       ~11     995, 'size'
    8     4        INIT_ARRAY                                       ~12     !0
          5        ADD_ARRAY_ELEMENT                                ~12     !1
          6        ADD_ARRAY_ELEMENT                                ~12     !2
          7        ADD_ARRAY_ELEMENT                                ~11     ~12, 'data'
    7     8        ASSIGN                                                   !3, ~11
   10     9        ASSIGN                                                   !4, null
   11    10        ASSIGN                                                   !5, 9000
   13    11        ASSIGN                                                   !6, 0
         12      > JMP                                                      ->22
   14    13    >   FETCH_DIM_R                                      ~17     !3, 'data'
         14        FETCH_DIM_R                                      ~18     ~17, !6
         15        ASSIGN                                                   !7, ~18
   15    16        FETCH_DIM_R                                      ~20     !7, 'service'
         17        IS_EQUAL                                                 !5, ~20
         18      > JMPZ                                                     ~21, ->21
   16    19    >   FETCH_DIM_R                                      ~22     !7, 'network'
         20        ASSIGN                                                   !4, ~22
   13    21    >   PRE_INC                                                  !6
         22    >   FETCH_DIM_R                                      ~25     !3, 'data'
         23        COUNT                                            ~26     ~25
         24        IS_SMALLER                                               !6, ~26
         25      > JMPNZ                                                    ~27, ->13
   20    26    > > JMPZ                                                     !4, ->32
   22    27    >   CONCAT                                           ~28     'Lookup+Results+for+', !5
         28        CONCAT                                           ~29     ~28, '%3A+'
         29        CONCAT                                           ~30     ~29, !4
         30        ECHO                                                     ~30
   20    31      > JMP                                                      ->33
   25    32    >   ECHO                                                     'Record+not+found'
   26    33    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.39 ms | 1003 KiB | 13 Q