I have a function that searches through an array of vegetable varieties to see if it matches an ID:
// my function
function findVariety($array, $key, $value)
{
$results = array();
if (is_array($array))
{
if (isset($array[$key]) && $array[$key] == $value)
$results[] = $array;
foreach ($array as $subarray)
$results = array_merge($results, findVariety($subarray, $key, $value));
}
return $results;
}
// function call
$picks = findVariety($veg,id,$sf->spring_choice);
when successful, it returns something like this:
// returned from print_r($picks);
Array ( [0] => Array ( [id] => 2 [variety] => Royal Burgundy (bush) ) )
All I’m missing is how to add the variety to an echo that I’m sending to my page, Ex:
echo '<td height="90px">'.$picks['variety'] .'<br /><a href="#" onclick="fill_square('.$a.','.$b.','.$box->id.','.$ID.');">add plants</a></td>';
As of now, I have been stuck on this last step! Any help would be amazing…
Your returned array is nested so to access the variety you’d need to do this: