Skip to main content

Read and write php arrays with python

Project description

php_whisperer

"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

PHP File:

<?php
# /tmp/a_php_file.php
$data = [
    "My Php Array" => [
        "You",
        "get",
        "the",
        "point"
    ]
];

Python Code:

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

Result:

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

Execute Arbitrary PHP

from php_whisperer import read_raw

php_code = """<?php

$v = explode(" ", "You get the point");
"""
data = read_raw(php_code, "v")
print(data)

Write PHP

Convert Python lists and dictionaries to PHP using generate_php

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

Result:

array(1, 2, 3, 4);

Modern syntax also available:

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

Result:

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

Source Distribution

php_whisperer-3.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

php_whisperer-3.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file php_whisperer-3.0.0.tar.gz.

File metadata

  • Download URL: php_whisperer-3.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.11

File hashes

Hashes for php_whisperer-3.0.0.tar.gz
Algorithm Hash digest
SHA256 db3edf58fde6bef1bdffe649abb589a7a77e1983fe394254c0ddfcc9314dd1a4
MD5 480be1952b7757821b7d58d5f5b44417
BLAKE2b-256 06fc595b5b6ef742e80fb1b4fc2a5310c520efae68e09f027bb53a9a19557174

See more details on using hashes here.

File details

Details for the file php_whisperer-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: php_whisperer-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.11

File hashes

Hashes for php_whisperer-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64cf9146e9507e28887776eeb101b609a1cc0b72e322b2f7094f88c4899374e4
MD5 6d23b46e3f8e050ca350d8763762fa01
BLAKE2b-256 0826b45435e98a727bfbec5c55fdb2d131147b68e6563e48dc41aeb5058708ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page