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

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 display values in a two dimensional array?


Thanks for your question.

You were along the right lines with the foreach command - you simply need to nest a foreach within another foreach, like this:

<?php
$myarray 
= array();
$myarray[0] = array(1,2,3,4);
$myarray[1] = array(5,6,7,8);
//
foreach($myarray as $v) {
foreach(
$v as $myv) {
echo 
"$myv<br>";
}
}
//prints 1 through 8 on screen
?>

Comments on this Question/Answer

What are the major difference between php4 and php5.
By: Sunil, 26 Jun 2009 21:50:23



Reply to comments / post your own comment >>>

ASK A QUESTION

More arrays PHP Questions

I'm shuffeling through numbers range(1, 10). Can I eval resulting random numbers and convert to appropriate text? 1 = username1, 2 = username2...etc?

How can I check if a value is already in an array?

How to point internal pointer to first element of an array?

How can I display a 2 dimensonal array?

How do I turn an array into a string?



Custom Search