Skip to main content

Read and write php arrays with python

Project description


"I heard you help people with PHP problems?" "Truth is, I help PHP with people problems."

Read PHP

Convert PHP arrays to Python objects using read_php

from php_whisperer import read_php
read_php('/tmp/a_php_file.php', variable='data')


{'My Php Array': ['You', 'get', 'the', 'point']}

Read many php files:

from php_whisperer import read_many

file1 = open('/tmp/php_file.php')
file2 = open('/tmp/php_file2.php')
file3 = open('/tmp/php_file3.php')
read_many(file1, file2, "$x = File1::doSomethingWith($something_from_file2)", file3, variable='x')


{'My Php Array': ['You', 'get', 'the', 'point']}

Write PHP

Convert Python lists and dictionaries to PHP using generate_php

from php_whisperer import generate_php
generate_php([1, 2, 3, 4])


array(1, 2, 3, 4);

Modern syntax also available:

from php_whisperer import generate_php
generate_php([1, 2, 3, 4], modern=True)


[1, 2, 3, 4];

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for php-whisperer, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size php_whisperer-2.0.0-py3-none-any.whl (6.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size php_whisperer-2.0.0.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page