I want to be able to select a specific array within an array without using a number position. The reason I don't want to a use a number position because the position will not always be equal based on the user logged in.
For instance, with the following array, I want to select only that of which has the x value of YourPhone.
The array structure:
$salesArray = array(
array(
'key' => 'Basic Planners',
'values' => array(
array('x' => 'YourPhone', 'y' => 150),
array('x' => 'Universe X3', 'y' => 300),
array('x' => 'ePhone 74s', 'y' => 1500),
array('x' => 'NextUs', 'y' => 50),
array('x' => 'Humanoid', 'y' => 500)
)
),
array(
'key' => 'No-Namers',
'values' => array(
array('x' => 'YourPhone', 'y' => 300),
array('x' => 'Universe X3', 'y' => 250),
array('x' => 'ePhone 74s', 'y' => 400),
array('x' => 'NextUs', 'y' => 150),
array('x' => 'Humanoid', 'y' => 900)
)
),
array(
'key' => 'Feature Followers',
'values' => array(
array('x' => 'YourPhone', 'y' => 359),
array('x' => 'Universe X3', 'y' => 900),
array('x' => 'ePhone 74s', 'y' => 100),
array('x' => 'NextUs', 'y' => 500),
array('x' => 'Humanoid', 'y' => 250)
)
),
array(
'key' => 'Hipsters & Elites',
'values' => array(
array('x' => 'YourPhone', 'y' => 200),
array('x' => 'Universe X3', 'y' => 350),
array('x' => 'ePhone 74s', 'y' => 50),
array('x' => 'NextUs', 'y' => 800),
array('x' => 'Humanoid', 'y' => 100)
)
)
);
Right now I'm selecting the values as such:
<?php $currentTeam = 0; ?>
<table>
<?php foreach ($sales as $sale) { ?>
<tr>
<td><?php echo $sale['key']; ?></td>
<td><?php echo $sale['values'][$currentTeam]['y']; ?></td>
</tr>
<?php } ?>
</table>