Holy nested arrays batman!
I think this is right:
<?php
$role = 'gold_membership';
foreach ($main_array as $set){
if ($set["conditions"][0]["args"]["roles"][0] == $role){
$amount = $set["rules"][0]["amount"];
break;
}
}
?>
$main_array is the array that contains all the elements similar to “set_5” and “set_6” etc. Note that $amount is a string representation of a number.
I don’t know of an easy way to reverse a var_dump or I would have tested this. If it doesn’t work, var_dump the specific values with the series of square brackets, except dropping the last bracket set. If the reason for my error doesn’t show up, drop the next last set until things make sense.
If all else fails, serialize the array and post that, then I’ll debug my code for you. It’s also possible to build a friendlier array instead of returning a single value if that helps. The array will look like
array('gold_membership'=>'50',
'silver_membership'=>'25',
'bronze_membership'=>'10');
Use this:
<?php
$friendly = array();
foreach ($main_array as $set){
$friendly[$set["conditions"][0]["args"]["roles"][0]] = $set["rules"][0]["amount"];
}
?>
`