I am using PHP CLI through the bash shell. Please check Array Manipulation (printed by php-cli) in the shell script for details.
The following code shell I can track down a pair of key
- value
, which I get from a PHP script.
IFS=":" # parse PHP output by read command php $PWD'/test.php' | while read -r key val; do echo $key":"$val done
Below is the output for this -
BASE_PATH:/path/to/project/root db_host:localhost db_name:database db_user:root db_pass:root
Now I just want to initiate dynamic variables inside the while loop so that I can use them, for example $BASE_PATH
with value '/path/to/project/root'
, $db_host
with 'localhost'
I come from the background of PHP. I would like something like $$key = $val
PHP
source share