I’m trying to get the value of the array, but I just cant quite get to it. I’m trying with a foreach loop and with key and values. But I can’t get it right. I’m working with wordpress custom field, and I’m trying to retrieve product ID, so that I can manipulate website data.
This is the array:
'Izbrani izdelki' array ( 0 => array ( 'product' => 34, ), 1 => array ( 'product' => 35, ), 2 => array ( 'product' => 41, ), 3 => array ( 'product' => 51, ), 4 => array ( 'product' => 40, ), ) 'Novo v naši ponudbi' array ( 0 => array ( 'product' => 35, ), 1 => array ( 'product' => 35, ), 2 => array ( 'product' => 32, ), 3 => array ( 'product' => 51, ), 4 => array ( 'product' => 37, ), ) 'Najbolj prodajani izdelki' array ( 0 => array ( 'product' => 34, ), 1 => array ( 'product' => 41, ), 2 => array ( 'product' => 35, ), 3 => array ( 'product' => 51, ), 4 => array ( 'product' => 39, ), ) 'Odprodaja' array ( 0 => array ( 'product' => 36, ), 1 => array ( 'product' => 34, ), 2 => array ( 'product' => 41, ), 3 => array ( 'product' => 51, ), 4 => array ( 'product' => 41, ), )
And I’m trying to retrieve value “product”, to be more specific the value number that’s inside with this approach:
<?php foreach ($tabTitle as $key => $value): ?> <?php foreach ($value as $key2 => $value2): ?> <?php echo "<pre>"; var_dump( $value2); echo "</pre>"; ?> <?php endforeach; ?> <?php endforeach; ?>
Advertisement
Answer
I did like this and it works now..
<?php foreach ($tabTitle as $key => $value): ?> <?php foreach ($value['products'] as $key2 => $value2): ?> <?php echo "<pre>"; var_export( $value2['product']); echo "</pre>"; ?> <?php endforeach; ?> <?php endforeach; ?>