开发者

How to get specific instance in PHP array?

开发者 https://www.devze.com 2023-03-23 20:41 出处:网络
I am trying to get the specific value of file extension in this array. All I can do so far is . I am wanting the fileextention \".jpg\"

I am trying to get the specific value of file extension in this array. All I can do so far is .

I am wanting the fileextention ".jpg"

All I know how to do is echo the values like so using foreach;

file_nameBob7213.jpg file_typeimage/jpeg
file_pathC:/xampp/htdocs/midas/records/
full_pathC:/xampp/htdocs/midas/records/Bob7213.jpg raw_nameB开发者_如何学Cob7213
orig_nameBob72.jpg client_nameafasfafs.jpg **file_ext.jpg** file_size44.96
is_image1 image_width716 image_height474 image_typejpeg
image_size_strwidth="716" height="474"

I am only interested in retrieving the file_ext from this array. How do I select that exact thing?

foreach ($file['upload_data'] as $item => $value)
{
  echo $item; echo $value; echo "<br/>";
}

How do I do this? , thanks!


$file['upload_data']['file_ext']

It's just an array within an array, so specify 2 array keys

Incidentally, if you want to see the contents of an array, a quick way of doing it is to use var_export:

var_export($file); # echoes the entire array

You don't need to write a foreach loop every time


$file['upload_data']['file_ext'] contains '.jpg'.

0

精彩评论

暂无评论...
验证码 换一张
取 消