Created
March 14, 2014 21:01
-
-
Save theY4Kman/9556817 to your computer and use it in GitHub Desktop.
Return a PHP print_r of a JSON encoded object... I use it to show dict structures to PHP peeps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import subprocess | |
| def php_print_r(obj): | |
| return subprocess.Popen(['php', '-r', 'print_r(json_decode(file_get_contents("php://stdin")));'], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(json.dumps(obj))[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment