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 hashes)
Built Distribution
Close
Hashes for php_whisperer-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64cf9146e9507e28887776eeb101b609a1cc0b72e322b2f7094f88c4899374e4 |
|
MD5 | 6d23b46e3f8e050ca350d8763762fa01 |
|
BLAKE2b-256 | 0826b45435e98a727bfbec5c55fdb2d131147b68e6563e48dc41aeb5058708ca |