Php Array display issue (syntax?)

Posted on 2011-03-02
Medium Priority
Last Modified: 2012-05-11
Hi all,

I have this array which contains the info when I use:


Ths above works fine BUT when I did this:

echo $myArray[0];  

I just get the word Array and no result ... what am I doing wrong please?


Question by:error77
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
  • 4
  • 2
  • 2
  • +1
LVL 31

Expert Comment

by:Marco Gasi
ID: 35017976
I should know how is created this array but try this

echo $myArray[0][0]

Maybe your array is build as an array of array... Try to post the output of var_dump, please

LVL 13

Expert Comment

ID: 35018002
As an example:

echo $c[0];

Open in new window

outputs "tt"

Can you show your output?

Author Comment

ID: 35018069
This is the output of the var_dump

array(1) { [0]=> array(7) { ["uid"]=> string(15) "112211133322" ["name"]=> string(21) "my name" ["pic"]=> string(77) "http://pro.com/34544544545.jpg" ["is_app_user"]=> string(1) "1" ["birthday_date"]=> string(0) "" ["sex"]=> string(4) "male" ["email"]=> string(0) "" } }

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

LVL 13

Accepted Solution

darren-w- earned 2000 total points
ID: 35018134
You will need to do something like:

echo [0]["uid"]
echo [0]["name"]
echo [0]["pic"]

LVL 13

Expert Comment

ID: 35018161
or something like

for each ($myArray[0] as  $key => $value ){
echo $key." :".$value;
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35018244
This is right: your $myArray contains an array inside, having 7 keys with values (an array inside an array).

Author Closing Comment

ID: 35018310
LVL 31

Expert Comment

by:Marco Gasi
ID: 35018476
Think you should split points... Without knowing your output I've shown you the probelm and the solution (changing the index type accordingly): don't you agree?
LVL 13

Expert Comment

ID: 35018646
I agree,

my example is incorrect it should read:

echo $myArray[0]["uid"]
echo $myArray [0]["name"]
echo $myArray[0]["pic"]

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 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