3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 0 => ['ид' => 1, 'тайтл' => '...', 'текст' => '2....',], 1 => ['ид' => 2, 'тайтл' => '...', 'текст' => '4....',], 2 => ['ид' => 3, 'тайтл' => '...', 'текст' => '1....',], ]; $array = AscOrderArray($array, 'текст'); print_r($array); function DescOrderArray($array, $field) { usort($array, function ($b, $a) use ($field) { return strnatcmp($a[$field], $b[$field]); }); return $array; } function AscOrderArray($array, $field) { usort($array, function ($a, $b) use ($field) { return strnatcmp($a[$field], $b[$field]); }); return $array; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VOpiA
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
    8     1        INIT_FCALL_BY_NAME                                           'AscOrderArray'
          2        SEND_VAR_EX                                                  !0
          3        SEND_VAL_EX                                                  '%D1%82%D0%B5%D0%BA%D1%81%D1%82'
          4        DO_FCALL                                          0  $2      
          5        ASSIGN                                                       !0, $2
   10     6        INIT_FCALL                                                   'print_r'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                                     
   28     9      > RETURN                                                       1

Function descorderarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VOpiA
function name:  DescOrderArray
number of ops:  10
compiled vars:  !0 = $array, !1 = $field
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   14     2        INIT_FCALL                                                   'usort'
          3        SEND_REF                                                     !0
          4        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          5        BIND_LEXICAL                                                 ~2, !1
   16     6        SEND_VAL                                                     ~2
   14     7        DO_ICALL                                                     
   18     8      > RETURN                                                       !0
   19     9*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VOpiA
function name:  {closure:DescOrderArray():14}
number of ops:  11
compiled vars:  !0 = $b, !1 = $a, !2 = $field
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   15     3        INIT_FCALL                                                   'strnatcmp'
          4        FETCH_DIM_R                                          ~3      !1, !2
          5        SEND_VAL                                                     ~3
          6        FETCH_DIM_R                                          ~4      !0, !2
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                             $5      
          9      > RETURN                                                       $5
   16    10*     > RETURN                                                       null

End of Dynamic Function 0

End of function descorderarray

Function ascorderarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VOpiA
function name:  AscOrderArray
number of ops:  10
compiled vars:  !0 = $array, !1 = $field
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   23     2        INIT_FCALL                                                   'usort'
          3        SEND_REF                                                     !0
          4        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          5        BIND_LEXICAL                                                 ~2, !1
   25     6        SEND_VAL                                                     ~2
   23     7        DO_ICALL                                                     
   27     8      > RETURN                                                       !0
   28     9*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VOpiA
function name:  {closure:AscOrderArray():23}
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $field
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   24     3        INIT_FCALL                                                   'strnatcmp'
          4        FETCH_DIM_R                                          ~3      !0, !2
          5        SEND_VAL                                                     ~3
          6        FETCH_DIM_R                                          ~4      !1, !2
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                             $5      
          9      > RETURN                                                       $5
   25    10*     > RETURN                                                       null

End of Dynamic Function 0

End of function ascorderarray

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
188.82 ms | 2240 KiB | 16 Q