Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Created March 14, 2014 21:01
Show Gist options
  • Select an option

  • Save theY4Kman/9556817 to your computer and use it in GitHub Desktop.

Select an option

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.
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