Retrieving Value from an Array - stdclass Object?

Posted on 2015-02-04
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:
it returns...
    [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!
Question by:erzoolander
  • 2

Accepted Solution

Ahmed Merghani earned 500 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);

Open in new window


Author Closing Comment

ID: 40589790

Expert Comment

by:Ahmed Merghani
ID: 40590445
You are welcome

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

929 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now