How to use an associative array value for calculation in PHP? -


i performing calculation using user input , associative arrays. below php code

$class          = $_post['class']; $size           = $_post['size']; $gasket         = $_post['gasket']; $connection     = $_post['connection'];  $flange150 = array(      array( flangesize  => 0.5,      /* inches */         flangeclass => 150,         flangethick => 0.38,     /* inches */         boltdia     => 0.5,      /* inches */         totalbolt   => 4     ),     array( flangesize  => 0.75,     /* inches */             flangeclass => 150,             flangethick => 0.44,     /* inches */             boltdia     => 0.5,      /* inches */             totalbolt   => 4     ),  ); 

the user input size stored in variable $size , using variable need select array has same value user input (flangesize in array). array must take value of flangethick calculation. dont know how perform this. please me in regard.

use foreach this

$flangethick = ""; foreach ($flange150 $key =>$val) {       if ($val['flangesize'] == $_post['size']) {            $flangethick = $val['flangethick'];       } } echo $flangethick; 

so, have value


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -