I’m trying to make something a little bit lighter. There’s this Python function I use for calculations, and it returns me an object like this :
result = {
'density': data.density,
'specific_heat': data.specific_heat,
'dynamic_viscosity': data.dynamic_viscosity,
'conductivity': data.conductivity,
'prandtl': data.prandtl
}
What I want to do is to create different variables in my PHP containing the different attributes. This is how I do it for now :
result = myPythonFunction();
$rho_prim = result['density'];
$cp_prim = result['specific_heat'];
$mu_prim = result['dynamic_viscosity'];
$lambda_prim = result['conductivity'];
$pr_prim = result['prandtl'];
And it works, but I wonder if there’s a shorter way. Plus, sometimes I won’t need all of the data, but just (for example) the density and the conductivity.
Maybe it is a pretty easy problem, but honestly I don’t know what to look for on the documentation. In Javascript I remember that ...Object
was doing almost what I want.
I tried to use arrays, but it doesn’t look that good.