3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "id": "bitcoin", "name": "Bitcoin", "symbol": "BTC", "rank": "1", "price_usd": "7365.07", "price_btc": "1.0", "24h_volume_usd": "4900640000.0", "market_cap_usd": "124873929597", "available_supply": "16954887.0", "total_supply": "16954887.0", "max_supply": "21000000.0", "percent_change_1h": "0.55", "percent_change_24h": "5.92", "percent_change_7d": "-7.93", "last_updated": "1522733968", "price_eur": "5987.30108524", "24h_volume_eur": "3983887076.48", "market_cap_eur": "101514013335" }, { "id": "ethereum", "name": "Ethereum", "symbol": "ETH", "rank": "2", "price_usd": "397.12", "price_btc": "0.0541563", "24h_volume_usd": "1216740000.0", "market_cap_usd": "39149486407.0", "available_supply": "98583517.0", "total_supply": "98583517.0", "max_supply": null, "percent_change_1h": "0.07", "percent_change_24h": "3.51", "percent_change_7d": "-15.33", "last_updated": "1522733953", "price_eur": "322.83155584", "24h_volume_eur": "989126881.68", "market_cap_eur": "31825870284.0" } ]'; $arr = array( (object) array('id'=>42, 'user_id'=>39, 'coin_rank'=>2), (object) array('id'=>3, 'user_id'=>39, 'coin_rank'=>6), (object) array('id'=>8, 'user_id'=>39, 'coin_rank'=>8), ); $jsonArr = json_decode($json, true); $new = array(); foreach($arr as $v){ $key = array_search($v->coin_rank, array_column($jsonArr, 'rank')); if($key !== false){ $new[] = $jsonArr[$key]; } } print_r($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 32
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 32
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/CU1AJ
function name:  (null)
number of ops:  37
compiled vars:  !0 = $json, !1 = $arr, !2 = $jsonArr, !3 = $new, !4 = $v, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A++++%7B%0A+++++++++%22id%22%3A+%22bitcoin%22%2C+%0A+++++++++%22name%22%3A+%22Bitcoin%22%2C+%0A+++++++++%22symbol%22%3A+%22BTC%22%2C+%0A+++++++++%22rank%22%3A+%221%22%2C+%0A+++++++++%22price_usd%22%3A+%227365.07%22%2C+%0A+++++++++%22price_btc%22%3A+%221.0%22%2C+%0A+++++++++%2224h_volume_usd%22%3A+%224900640000.0%22%2C+%0A+++++++++%22market_cap_usd%22%3A+%22124873929597%22%2C+%0A+++++++++%22available_supply%22%3A+%2216954887.0%22%2C+%0A+++++++++%22total_supply%22%3A+%2216954887.0%22%2C+%0A+++++++++%22max_supply%22%3A+%2221000000.0%22%2C+%0A+++++++++%22percent_change_1h%22%3A+%220.55%22%2C+%0A+++++++++%22percent_change_24h%22%3A+%225.92%22%2C+%0A+++++++++%22percent_change_7d%22%3A+%22-7.93%22%2C+%0A+++++++++%22last_updated%22%3A+%221522733968%22%2C+%0A+++++++++%22price_eur%22%3A+%225987.30108524%22%2C+%0A+++++++++%2224h_volume_eur%22%3A+%223983887076.48%22%2C+%0A+++++++++%22market_cap_eur%22%3A+%22101514013335%22%0A+++++%7D%2C+%0A+++++%7B%0A+++++++++%22id%22%3A+%22ethereum%22%2C+%0A+++++++++%22name%22%3A+%22Ethereum%22%2C+%0A+++++++++%22symbol%22%3A+%22ETH%22%2C+%0A+++++++++%22rank%22%3A+%222%22%2C+%0A+++++++++%22price_usd%22%3A+%22397.12%22%2C+%0A+++++++++%22price_btc%22%3A+%220.0541563%22%2C+%0A+++++++++%2224h_volume_usd%22%3A+%221216740000.0%22%2C+%0A+++++++++%22market_cap_usd%22%3A+%2239149486407.0%22%2C+%0A+++++++++%22available_supply%22%3A+%2298583517.0%22%2C+%0A+++++++++%22total_supply%22%3A+%2298583517.0%22%2C+%0A+++++++++%22max_supply%22%3A+null%2C+%0A+++++++++%22percent_change_1h%22%3A+%220.07%22%2C+%0A+++++++++%22percent_change_24h%22%3A+%223.51%22%2C+%0A+++++++++%22percent_change_7d%22%3A+%22-15.33%22%2C+%0A+++++++++%22last_updated%22%3A+%221522733953%22%2C+%0A+++++++++%22price_eur%22%3A+%22322.83155584%22%2C+%0A+++++++++%2224h_volume_eur%22%3A+%22989126881.68%22%2C+%0A+++++++++%22market_cap_eur%22%3A+%2231825870284.0%22%0A+++++%7D%0A+++%5D'
   46     1        CAST                                          8  ~7      <array>
          2        INIT_ARRAY                                       ~8      ~7
   47     3        CAST                                          8  ~9      <array>
          4        ADD_ARRAY_ELEMENT                                ~8      ~9
   48     5        CAST                                          8  ~10     <array>
          6        ADD_ARRAY_ELEMENT                                ~8      ~10
   45     7        ASSIGN                                                   !1, ~8
   51     8        INIT_FCALL                                               'json_decode'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !2, $12
   52    13        ASSIGN                                                   !3, <array>
   53    14      > FE_RESET_R                                       $15     !1, ->32
         15    > > FE_FETCH_R                                               $15, !4, ->32
   54    16    >   INIT_FCALL                                               'array_search'
         17        FETCH_OBJ_R                                      ~16     !4, 'coin_rank'
         18        SEND_VAL                                                 ~16
         19        INIT_FCALL                                               'array_column'
         20        SEND_VAR                                                 !2
         21        SEND_VAL                                                 'rank'
         22        DO_ICALL                                         $17     
         23        SEND_VAR                                                 $17
         24        DO_ICALL                                         $18     
         25        ASSIGN                                                   !5, $18
   55    26        TYPE_CHECK                                  1018          !5
         27      > JMPZ                                                     ~20, ->31
   56    28    >   FETCH_DIM_R                                      ~22     !2, !5
         29        ASSIGN_DIM                                               !3
         30        OP_DATA                                                  ~22
   53    31    > > JMP                                                      ->15
         32    >   FE_FREE                                                  $15
   59    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.05 ms | 1006 KiB | 17 Q