Simple variable assignment from two-dimensional array in php -


i have two-dimensional array 2 key values, [program] , [balance], created mysql select statement in wordpress. know values of [program] (they never change) - it's balances i'm interested in.

for example:

*[program] = 'sales', [balance] = 10,000*  *[program] = 'commission', [balance] = 1,250* 

all want assign balance value variable, have:

*$sales = (the balance sales program)*  *$commission = (the balance commission program)* 

i know i'm being thick here, cannot see how after hour of searching , screwing around php. it's total brain block , references can find online talk loops , echoing values , stuff.

would appreciate de-blocking!

//make function function findbalancebyprogram($inputarray,$program)  //loop trough keys on first dimension  foreach($inputarray $val){     //check in second dimension if program same program checking     if($val['program']==$program)        //if so.. return value , jump out of function       return $val['balance'];   } }  //an example of use. echo findbalancebyprogram($yourarray,'sales'); 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -