Skip to content

Instantly share code, notes, and snippets.

@foospidy
Created September 29, 2016 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save foospidy/52adf3ccd7e9116f4849dbdf855072d8 to your computer and use it in GitHub Desktop.
Save foospidy/52adf3ccd7e9116f4849dbdf855072d8 to your computer and use it in GitHub Desktop.
Convert a string to a PHP array in the implode function.
#!/usr/bin/python
#
# str2implode.py
#
# Usage: python str2implody.py "example string with spaces"
#
import sys
out = ""
for c in sys.argv[1]:
out = out + "chr(" + str(ord(c)) + "),"
print "implode(NULL, array(" + out + "))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment