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
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 execute_php
python_list = execute_php([
"@require '/home/me/a_php_file.php'",
"$arr = [];",
"foreach ($var_from_php_file as $k => $v) {",
" if (strlen($k) > 5) $arr[] = $v;",
"}",
variable="arr"
])
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.1.1.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for php_whisperer-2.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e03feca4868c0d1ddb43f23204f5d9030fd19a0eba5c04487a242fc11af64db3 |
|
MD5 | 06043bf64b2a807cb47680b4f1a75595 |
|
BLAKE2b-256 | 3a51551800bc837594fef78c832021420f718bf0910b67d31e78ac3f9163f06c |