SHARE
TWEET

Untitled

a guest Apr 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/php
  2. <?php
  3. function isAssoc(array $arr): bool
  4. {
  5.     if (array() === $arr) return false;
  6.     return array_keys($arr) !== range(0, count($arr) - 1);
  7. }
  8.  
  9. function dump($a): string
  10. {
  11.     if (is_array($a)) {
  12.         if (isAssoc($a)) {
  13.             $chunks = array_map(function($k, $v) {
  14.                 return sprintf('%s => %s', dump($k), dump($v));
  15.             }, array_keys($a), $a);
  16.         } else {
  17.             $chunks = array_map(function($v) {
  18.                 return dump($v);
  19.             }, $a);
  20.         }
  21.         return sprintf('[%s]', implode(', ', $chunks));
  22.     }
  23.     return var_export($a, true);
  24. }
  25.  
  26. $data = $argv[1] ?? null;
  27. printf("%s\n", dump(json_decode($data, true)));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top