So I've been pulling my hair trying to figure out why the output is showing an Array
text instead of displaying the actual values. Below is an array that I'm trying to fetch the values.
array(4) {
[0]=>
array(3) {
[0]=>
string(6) "400 ml"
[1]=>
string(2) "1L"
[2]=>
string(2) "2L"
}
[1]=>
array(8) {
[0]=>
string(17) "100% Orange Juice"
[1]=>
string(5) "Apple"
[2]=>
string(4) "Pear"
[3]=>
string(9) "Pineapple"
[4]=>
string(12) "Passionfruit"
[5]=>
string(15) "Red Dragonfruit"
[6]=>
string(13) "Baobab Powder"
[7]=>
string(17) "Grapeseed Extract"
}
[2]=>
array(1) {
[0]=>
string(3) "Yes"
}
[3]=>
array(1) {
[0]=>
string(3) "Yes"
}
}
If I tried looping through it using foreach
it gives me the output Array Array Array Array
foreach($singleArray as $key => $val) {
echo $val;
}
If I tried specifying the index like below, it gives me the actual values
foreach($singleArray[0] as $key => $val) {
echo $val;
}