How can I parse the result of var_dump in PHP? My PHP code calls a Python script as follows:
exec("python /home/content/51/5159651/html/perl/test_python.py $a0 $a1", $output);
var_dump($output);
where $a0 and $a1 are integers. test_python.py multiplies $a0 and $a1 correctly, but the result (for $a0=5 and $a1=7) of var_dump($output) is
array(1) { [0]=> string(2) "35" }
All I want is the answer, 35. Yes, I can parse the result using regex, but there must be a simpler way - e.g. something other than var_dump. The code for test_python.py is below, and I would be happy to modify it to get a simpler way to extract the result.
#!/usr/bin/python
import sys
parameter1=int(sys.argv[1]);
parameter2=int(sys.argv[2]);
def main(parameter1, parameter2):
output = parameter1*parameter2
return output
output=main(parameter1, parameter2);
print(output);