CodeIgniter Forums
accessing an element in an array of arrays - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: accessing an element in an array of arrays (/showthread.php?tid=78975)



accessing an element in an array of arrays - richb201 - 04-03-2021

PHP Code:
$files_to_upload = Array
(
        [sd1e6fec1] => Array
        (
                [name] => 86.jpg
                
[type] => image/jpeg
                
[tmp_name] => C:\wamp\tmp\phpFC42.tmp
                
[error] => 0
                
[size]  => 258177
        
)






I am trying to access the size element using this:
$size=$files_to_upload[$name].size;

when I run this I get $size="Arraysize". I am just trying ti get the size element.  How can get that 258177 number?

$name is a string that I got from another structure.



RE: accessing an element in an array of arrays - InsiteFX - 04-03-2021

For what you want it should be something like this not tested. It depends on if you know the keys value.

PHP Code:
$size $files_to_upload['sd1e6fec1']['size']; 

try that


RE: accessing an element in an array of arrays - richb201 - 04-03-2021

works! thx