3v4l.org

run code in 300+ PHP versions simultaneously
<?php function findDupl($arr,$n){ $result_arr = array_count_values(array_column($arr, $n)); foreach ($result_arr as $k => $value){ if(emailValid($k) && $value>1){ $res[$k] = $value; } } return $res; } function emailValid($mail){ // Validate email if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { //echo("$email is a valid email address"); return true; } else { //echo("$email is not a valid email address"); return false; } } function unique_multidim_array($array, $key) { $temp_array = array(); $i = 0; $key_array = array(); foreach($array as $val) { if (!in_array($val[$key], $key_array)) { $key_array[$i] = $val[$key]; if(emailValid($key_array[$i]) ){ $temp_array[$i] = $val; } } $i++; } return array_values($temp_array); } $lista = array( array("Generale","","","","Ospite","","",""),array("Num","Alloggio","Arrivo","Partenza","Intestazione","Telefono","email","Nazione"), array(4388,"Sogno Azzurro - Trilocale Superior (9)","2023-04-06","2023-04-10","TEST PROVA","3484403960","prenotazioni@ibookingelba.com","IT"), array(4435,"Villetta Paradiso","2023-04-07","2023-04-16","TEST PROVA","+41772081329","prenotazioni@ibookingelba.com","CH"), array(4435,"Villetta Paradiso","2023-04-07","2023-04-16","TEST PROVA","+41772081329","preno@ibookingelba.com","CH") ); print_r($lista); echo "*********"; //$materials = array_count_values(array_column($lista, 6)); print_r(findDupl($lista,6)); $arr_duplicati = findDupl($lista,6); //$keys = array_keys($arr_duplicati); echo $key = key($arr_duplicati); echo $value = reset($arr_duplicati);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tgT43
function name:  (null)
number of ops:  28
compiled vars:  !0 = $lista, !1 = $arr_duplicati, !2 = $key, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ASSIGN                                                   !0, <array>
   42     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   43     4        ECHO                                                     '%2A%2A%2A%2A%2A%2A%2A%2A%2A'
   46     5        INIT_FCALL                                               'print_r'
          6        INIT_FCALL                                               'finddupl'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 6
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                                 
   48    12        INIT_FCALL                                               'finddupl'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 6
         15        DO_FCALL                                      0  $8      
         16        ASSIGN                                                   !1, $8
   50    17        INIT_FCALL                                               'key'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $10     
         20        ASSIGN                                           ~11     !2, $10
         21        ECHO                                                     ~11
   51    22        INIT_FCALL                                               'reset'
         23        SEND_REF                                                 !1
         24        DO_ICALL                                         $12     
         25        ASSIGN                                           ~13     !3, $12
         26        ECHO                                                     ~13
         27      > RETURN                                                   1

Function finddupl:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 22
Branch analysis from position: 19
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/tgT43
function name:  findDupl
number of ops:  26
compiled vars:  !0 = $arr, !1 = $n, !2 = $result_arr, !3 = $value, !4 = $k, !5 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'array_count_values'
          3        INIT_FCALL                                               'array_column'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
    4    10      > FE_RESET_R                                       $9      !2, ->23
         11    > > FE_FETCH_R                                       ~10     $9, !3, ->23
         12    >   ASSIGN                                                   !4, ~10
    5    13        INIT_FCALL_BY_NAME                                       'emailValid'
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0  $12     
         16      > JMPZ_EX                                          ~13     $12, ->19
         17    >   IS_SMALLER                                       ~14     1, !3
         18        BOOL                                             ~13     ~14
         19    > > JMPZ                                                     ~13, ->22
    6    20    >   ASSIGN_DIM                                               !5, !4
         21        OP_DATA                                                  !3
    4    22    > > JMP                                                      ->11
         23    >   FE_FREE                                                  $9
    9    24      > RETURN                                                   !5
   10    25*     > RETURN                                                   null

End of function finddupl

Function emailvalid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tgT43
function name:  emailValid
number of ops:  10
compiled vars:  !0 = $mail
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'filter_var'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 274
          4        DO_ICALL                                         $1      
          5      > JMPZ                                                     $1, ->8
   15     6    > > RETURN                                                   <true>
          7*       JMP                                                      ->9
   18     8    > > RETURN                                                   <false>
   20     9*     > RETURN                                                   null

End of function emailvalid

Function unique_multidim_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 26
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/tgT43
function name:  unique_multidim_array
number of ops:  32
compiled vars:  !0 = $array, !1 = $key, !2 = $temp_array, !3 = $i, !4 = $key_array, !5 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        ASSIGN                                                   !2, <array>
   23     3        ASSIGN                                                   !3, 0
   24     4        ASSIGN                                                   !4, <array>
   25     5      > FE_RESET_R                                       $9      !0, ->26
          6    > > FE_FETCH_R                                               $9, !5, ->26
   26     7    >   INIT_FCALL                                               'in_array'
          8        FETCH_DIM_R                                      ~10     !5, !1
          9        SEND_VAL                                                 ~10
         10        SEND_VAR                                                 !4
         11        DO_ICALL                                         $11     
         12        BOOL_NOT                                         ~12     $11
         13      > JMPZ                                                     ~12, ->24
   27    14    >   FETCH_DIM_R                                      ~14     !5, !1
         15        ASSIGN_DIM                                               !4, !3
         16        OP_DATA                                                  ~14
   28    17        INIT_FCALL                                               'emailvalid'
         18        FETCH_DIM_R                                      ~15     !4, !3
         19        SEND_VAL                                                 ~15
         20        DO_FCALL                                      0  $16     
         21      > JMPZ                                                     $16, ->24
   29    22    >   ASSIGN_DIM                                               !2, !3
         23        OP_DATA                                                  !5
   32    24    >   PRE_INC                                                  !3
   25    25      > JMP                                                      ->6
         26    >   FE_FREE                                                  $9
   35    27        INIT_FCALL                                               'array_values'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $19     
         30      > RETURN                                                   $19
   36    31*     > RETURN                                                   null

End of function unique_multidim_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.89 ms | 1407 KiB | 32 Q