Php Array display issue (syntax?)

Hi all,

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

var_dump($myArray);

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?

Thanks


error77Asked:
Who is Participating?
 
darren-w-Connect With a Mentor Commented:
You will need to do something like:

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

etc...
0
 
Marco GasiFreelancerCommented:
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

Cheers
0
 
darren-w-Commented:
As an example:

$c=array("tt");
echo $c[0];

Open in new window


outputs "tt"

Can you show your output?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
error77Author Commented:
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) "" } }


0
 
darren-w-Commented:
or something like

for each ($myArray[0] as  $key => $value ){
echo $key." :".$value;
}
0
 
Lukasz ChmielewskiCommented:
This is right: your $myArray contains an array inside, having 7 keys with values (an array inside an array).
0
 
error77Author Commented:
Thanks
0
 
Marco GasiFreelancerCommented:
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?
0
 
darren-w-Commented:
I agree,

my example is incorrect it should read:

echo $myArray[0]["uid"]
echo $myArray [0]["name"]
echo $myArray[0]["pic"]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.