I have a json_decode array which I can access the values fine with a foreach
like this :
foreach ($prodvariants["result"]["sync_variants"] as $variant) {
echo $product_name = $variant['product']['name'];
}
This works great.
But what if I do not want a foreach
? How can I access the same values but without the forloop?
I tried this
$variant =$prodvariants["result"]["sync_variants"];
echo $product_name = $variant['product']['name'];
But when I try it like this,without the foreach
I get error
Notice: Undefined index: product