How can I loop through a set of session arrays and check if $_session['items'][1][p_alt-variation-1] etc. $_session['items'][1][p_alt-variation-1] ? [p_alt-variant- {n}] elements are dynamic if a certain element has these additional modifications, so it can be no more than 1
print_r ($ _ SESSION ['elements'])
Array ( [0] => Array ( [p_name] => Hovid PetSep [p_code] => 336910 [p_coverImg] => 14-1460428610-ulNvG.jpg [p_id] => 14 [p_price] => 24.50 [p_qty] => 2 ) [1] => Array ( [p_name] => X-Dot Motorbike Helmet G88 + Bogo Visor (Tinted) [p_code] => 2102649 [p_coverImg] => 12-1460446199-wI5qx.png [p_id] => 12 [p_price] => 68.00 [p_alt-variation-1] => Red [p_alt-variation-2] => L [p_qty] => 1 ) )
I want to show the user if a certain element has different options in their cart, if they exist, how to search for an element in an array if it contains a string like [p_alt-variant- {n}] through?
I use foreach($_SESSION['items'] as $cart_item){ ... } to combine all the cart items to display product information.
Thanks for the advice.
source share