PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How can I easily view all members of an array?


To view all the members of an array with minimal code, the simplest way is to use print_r - this will show you the members of an array like this:

<?php
$values 
= array("banana","apple","pear","banana");
print_r($values);
?>


Outputs:

Array
(
[0] => banana
[1] => apple
[2] => pear
[3] => banana
)

Less well known but useful when you require more detailed information on each array member is the function var_dump.

This will return the below for the array members above:

array(4) {
[0]=>
string(6) "banana"
[1]=>
string(5) "apple"
[2]=>
string(4) "pear"
[3]=>
string(6) "banana"
}



ASK A QUESTION

More arrays PHP Questions

what are php array functions?

i need to store a multi-dimensioned array into a file. there is plenty of info. on creating md-arrays but i cant find anything on writing a md-array to a file.

How can I create an array of numbers easily?

How can I reverse sort an array keeping the correlation between the index and value?

I have the following list : Tom T1 Tom T2 Bill T1 Bill T2 Jack T1 Jack T2 I need it converted into : Tom T1,T2 Bill T1,T2 Jack T1,T2



Custom Search