3v4l.org

run code in 300+ PHP versions simultaneously
<?php $chords = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']; // Therefore, If the original chord is E and we want to transpose +1, the resulting chord is F. If we transpose +4, the resulting chord is G#. $index = array_search('E', $chords); // Transpose +4 to get the index of E, found above, +4 chords $chord = $chords[$index+4]; echo 'Chord: ' + $chord;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JTeir
function name:  (null)
number of ops:  12
compiled vars:  !0 = $chords, !1 = $index, !2 = $chord
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    7     1        INIT_FCALL                                               'array_search'
          2        SEND_VAL                                                 'E'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   10     6        ADD                                              ~6      !1, 4
          7        FETCH_DIM_R                                      ~7      !0, ~6
          8        ASSIGN                                                   !2, ~7
   12     9        ADD                                              ~9      'Chord%3A+', !2
         10        ECHO                                                     ~9
         11      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.62 ms | 1394 KiB | 15 Q