1

When I want to print the content of an Array, I always get the string "Array" instead of the content.

I've also tried: implode(",", $myArray);

but still I get "Array" rather than the content itself

4
  • 3
    Does $myArray contain nested arrays? Can you add the output of var_dump($myArray) to your question? Commented Nov 21, 2010 at 21:01
  • 3
    Add some more code and you could get some help. Commented Nov 21, 2010 at 21:01
  • Are you storing another array within that one? You may have to call implode() recursively. Commented Nov 21, 2010 at 21:01
  • What would you like the output to look like? (Serious question, will help us craft an answer.) Commented Nov 21, 2010 at 21:08

3 Answers 3

2

Use print_r() to recursively print arrays.

Sign up to request clarification or add additional context in comments.

Comments

2

implode() takes a maximum of two arguments:

 string implode ( string $glue , array $pieces )

Try var_dump(), var_export() or print_r() instead:

var_dump($myArray);
var_export($myArray);
print_r($myArray);

2 Comments

Where did he try to use implode() with more than two arguments?
Ah, I misread the question as two empty strings: implode('','', $myArray);
1
var_dump($theArray);

This prints out the array in nice tabbed format, with both the keys / indices, value types and values shown.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.