Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Mine
Monday, March 19th, 2007 at 12:47:14am UTC 

This post has 1 comment thread shown at the end of this page.

  1. <?php
  2.  
  3. $data = array("zoo", "orange", "car", "lemon", "apple");
  4. usort($data, function($a, $b) { return strcmp($a, $b); });
  5. var_dump($data);
  6.  
  7. echo "\n";
  8. ?>
  9.  
  10. outputs:
  11.  
  12. array(5) {
  13.   [0]=>
  14.   string(5) "apple"
  15.   [1]=>
  16.   string(3) "car"
  17.   [2]=>
  18.   string(5) "lemon"
  19.   [3]=>
  20.   string(6) "orange"
  21.   [4]=>
  22.   string(3) "zoo"
  23. }
  24.  
  25.  
  26. Made possible with this patch:
  27.  
  28.  
  29. diff -u -p -r1.160.2.4.2.3 zend_language_parser.y
  30. --- zend_language_parser.y      10 Jan 2007 15:58:07 -0000      1.160.2.4.2.3
  31. +++ zend_language_parser.y      18 Mar 2007 23:28:08 -0000
  32. @@ -620,6 +620,29 @@ expr_without_variable:
  33.         |       T_ARRAY '(' array_pair_list ')' { $$ = $3; }
  34.         |       '`' encaps_list '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); }
  35.         |       T_PRINT expr  { zend_do_print(&$$, &$2 TSRMLS_CC); }
  36. +       |       T_FUNCTION {
  37. +                       /* inline function declaration, its value is the function name */
  38. +                       char name[64];
  39. +                       int namelen;
  40. +                       static unsigned int anon_count;
  41. +                       namelen = zend_sprintf(name, "__zend_anon_%u", anon_count++);
  42. +                       $1.u.opline_num = CG(zend_lineno);
  43. +                       $$.op_type = IS_CONST;
  44. +                       $$.u.constant.type = IS_STRING;
  45. +                       $$.u.constant.value.str.val = estrdup(name);
  46. +                       $$.u.constant.value.str.len = namelen;
  47. +                       $$.u.constant.refcount = 1;
  48. +               } is_reference { zend_do_begin_function_declaration(&$1, &$$, 0, $2.op_type, NULL TSRMLS_CC); }
  49. +                       '(' parameter_list ')' '{' inner_statement_list '}' {
  50. +
  51. +                       $$.op_type = IS_CONST;
  52. +                       $$.u.constant.type = IS_STRING;
  53. +                       $$.u.constant.value.str.val = estrdup(CG(active_op_array)->function_name);
  54. +                       $$.u.constant.value.str.len = strlen($$.u.constant.value.str.val);
  55. +                       $$.u.constant.refcount = 1;
  56. +                       zend_do_end_function_declaration(&$1 TSRMLS_CC);
  57. +               }
  58. +
  59.  ;
  60.  
  61.  function_call:
  62. Index: zend_compile.c
  63. ===================================================================
  64. RCS file: /repository/ZendEngine2/zend_compile.c,v
  65. retrieving revision 1.647.2.27.2.32
  66. diff -u -p -r1.647.2.27.2.32 zend_compile.c
  67. --- zend_compile.c      12 Mar 2007 13:10:40 -0000      1.647.2.27.2.32
  68. +++ zend_compile.c      19 Mar 2007 00:46:44 -0000
  69. @@ -2339,6 +2339,12 @@ ZEND_API int do_bind_function(zend_op *o
  70.                 if (zend_hash_find(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void *) &function)==SUCCESS
  71.                         && function->type==ZEND_USER_FUNCTION
  72.                         && ((zend_op_array *) function)->last>0) {
  73. +
  74. +                       if (!memcmp(opline->op2.u.constant.value.str.val, "__zend_anon_", sizeof("__zend_anon_")-1)) {
  75. +                               (*function->op_array.refcount)++;
  76. +                               function->op_array.static_variables = NULL; /* NULL out the unbound function */
  77. +                               return SUCCESS;
  78. +                       }
  79.                         zend_error(error_level, "Cannot redeclare %s() (previously declared in %s:%d)",
  80.                                                 opline->op2.u.constant.value.str.val,
  81.                                                 ((zend_op_array *) function)->filename,

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus

comments on this paste

mine (#400952)

Posted: September 13th, 2015 at 10:12am UTC

1

worth-right
worth-right