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

I tried to query a table and retrieve some data, then I email them to an indivisual person with different data. However, I am only to send the 1st email, but not 2nd email. My query seem that not able to pass the 1st data found and pass it for 2nd time

How do I write my own sort function?

how do i send the information from one page to another page using post method.

How can I reset an array in PHP?

How may I keyboard replace the value of one cell of the array and the save that row to MySQL using PHP ?



Custom Search