?
Solved

Retrieving Value from an Array - stdclass Object?

Posted on 2015-02-04
3
Medium Priority
?
115 Views
Last Modified: 2015-02-04
I'm a little confused by what ought to be relatively simple syntax...

I have an array...called $files

When I call:
print_r(array_values($files));
it returns...
Array
(
    [0] => stdClass Object
        (
            [path] => /10432949_10152690623541547_915229621125343103_n.jpg
            [bytes] => 86524
            [modified] => Tue, 03 Feb 2015 21:32:13 +0000
        )

    [1] => stdClass Object
        (
            [path] => /islogo.jpg
            [bytes] => 7612
            [modified] => Wed, 28 Jan 2015 03:22:16 +0000
        )

    [2] => stdClass Object
        (
            [path] => /sample2.mp3
            [bytes] => 908625
            [modified] => Fri, 20 Jun 2014 14:55:38 +0000
        )

    [3] => stdClass Object
        (
            [path] => /test_download_sample2.mp3
            [bytes] => 908625
            [modified] => Sat, 27 Sep 2014 03:08:54 +0000
        )
)

Open in new window


Now - I want to retrieve the first value, second value, etc...  But when I put

print_r($files[0]) - it yields nothing.

What am I doing wrong?  Shouldn't that return the first array object?

Thanks in advance!
0
Comment
Question by:erzoolander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Ahmed Merghani earned 2000 total points
ID: 40589406
Because you print the array values of files not the array it self! So to be able to print it as files[0], it will be something like this:
$files_ary = array_values($files);
print_r(files_ary[0]);

Open in new window

0
 
LVL 2

Author Closing Comment

by:erzoolander
ID: 40589790
Gracias!
0
 
LVL 8

Expert Comment

by:Ahmed Merghani
ID: 40590445
You are welcome
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question