fork download
  1. <?php
  2. function enum($x) {
  3. $tmp = array_flip(preg_split('/\W+/', $x, -1, PREG_SPLIT_NO_EMPTY));
  4. array_walk($tmp, function($value, $key){$GLOBALS[$key] = $value;});
  5. }
  6.  
  7. enum(<<<'S'
  8.   NULL
  9.   ONE
  10.   TWO
  11.   THREE
  12.   FORTH
  13. S
  14. );
  15.  
  16. printf("%d %d %d %d %d\n", $NULL, $ONE, $TWO, $THREE, $FORTH);
  17.  
Success #stdin #stdout 0s 82624KB
stdin
Standard input is empty
stdout
0 1 2 3 4