I am printing array elements
foreach($subcategories as $sucategory){
print_r($sucategory);
echo $subcategory[2];
echo $subcategory[catid];
echo $subcategory['catid'];
echo $subcategory["catid"];
echo $subcategory{"catid"};
die();
}
The above code prints only the value of print_r($subcategory) but it didn't echo the value of catid in $subcategory..
Array
(
[id] => 5
[name] => 1
[catid] => 10
[status] => Y
)
and
echo $subcategories[0]['catid']; //prints 10 correctly
You have an error there. You use $sucategory and $subcategory, different names!
Copy/Paste this and it will work:
foreach($subcategories as $subcategory){
print_r($subcategory);
echo $subcategory["catid"];
die();
}