All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
PHP Multidimensional array output foreach loop
I'm having some issues figuring out a foreach loop with this multidimensional array:
The current loop:
<?php foreach ($data as $item => $value):?>
<li><?php echo $item;?>: <?php echo $value;?></li>
<?php endforeach; ?>
</ul>
My array.
object(stdClass)#28 (3) { ["file"]=> array(1) { ["upload_data"]=> array(14) { ["file_name"]=> string(36) "5a222f01f78f40d54b106c6135e5f15c.PNG" ["file_type"]=> string(9) "image/png" ["file_path"]=> string(38) "/uploads/1/" ["full_path"]=> string(74) "/uploads/1/5a222f01f78f40d54b106c6135e5f15c.PNG" ["raw_name"]=> string(32) "5a222f01f78f40d54b106c6135e5f15c" ["orig_name"]=> string(15) "itnightmare.PNG" ["client_name"]=> string(15) "itnightmare.PNG" ["file_ext"]=> string(4) ".PNG" ["file_size"]=> float(100.37) ["is_image"]=> bool(true) ["image_width"]=> int(835) ["image_height"]=> int(523) ["image_type"]=> string(3) "png" ["image_size_str"]=> string(24) "width="835" height="523"" } } ["artinfo"]=> array(8) { ["txtTitle"]=> string(22) "This is a piece of art" ["txtOriginDate"]=> string(4) "1853" ["txtDimensions"]=> string(8) "12x23x12" ["selectType"]=> string(8) "ppastels" ["chkFramed"]=> string(4) "true" ["txtInventoryNum"]=> string(7) "7845884" ["txtDescription"]=> string(33) "This is a description of the art." ["upload"]=> string(14) "Upload Artwork" } ["user"]=> object(stdClass)#25 (18) { ["id"]=> string(1) "1" ["ip_address"]=> string(4) "" ["username"]=> string(13) "administrator" ["password"]=> string(40) "59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4" ["salt"]=> string(10) "9462e8eee0" ["email"]=> string(15) "[email protected]" ["activation_code"]=> string(0) "" ["forgotten_password_code"]=> NULL ["forgotten_password_time"]=> NULL ["remember_code"]=> string(40) "9d029802e28cd9c768e8e62277c0df49ec65c48c" ["created_on"]=> string(10) "1268889823" ["last_login"]=> string(10) "1393856122" ["active"]=> string(1) "1" ["first_name"]=> string(5) "Admin" ["last_name"]=> string(8) "istrator" ["company"]=> string(5) "ADMIN" ["phone"]=> string(1) "0" ["user_id"]=> string(1) "1" } }
Can anyone provide some direction of foreach with multiple key values?
Comments
Wtf man...
<?php
foreach ($data as $index => $values){
foreach ($values as $key => $val){
//This will handle a two dimensional array
echo '['.$index.']['.$key.'] = '.$val;
}
}
//Or more simply... print_r the array
print_r($data);
?>
I know, a cluster of information. I don't need most of it right now, but in the event I need it for the future. Much appreciated!
Another approach would be to use objects.
<(no spaces) pre ><?php echo print_r($array); ?></ pre (no spaces) > would be the best way if you only want to see (print out) the information. if you need to do something with it, use massnode's code
I was var dumping, but I wanted a cleaner way to dump it than var_dump or print_r.
I should clarify VAR dumping. Sounds bad without context.
I'm not sure what you want then... Those two foreach loops iterate though a two dimensional array.
No, what you suggested was what I was looking for. Exactly it. Just adding to it.