• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

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


0
error77
Asked:
error77
  • 4
  • 2
  • 2
  • +1
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
darren-w-Commented:
You will need to do something like:

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

etc...
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now