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-2.2.0.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for php_whisperer-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81c6321a248a670a21f072b4b0f54364e8c3fd133e3a785423e6726656a5141f |
|
MD5 | 47b21e3418d42acb51f1b0ab212a3044 |
|
BLAKE2b-256 | 3cf431807693d8e67d73fa5f94edb33fc2f919196e2e1c6e9dbc3a6e569d5880 |