I have to print all values with one loop (IT DOESN'T NEED print_r[$array])
this is what i made til now but it isn't working properly -
$array = array(
-
array(11,12,13,14,15,16),
-
array(21,22,23,24,25,26),
-
array(31,32,33,34,35,36),
-
array(41,42,43,44,45,46),
-
array(51,52,53,54,55,56),
-
array(61,62,63,64,65,66)
-
);
-
-
-
$colindex = 0;
-
$rowindex = 0;
-
for ($i = 0; $i<35; $i++)
-
{
-
-
-
if($rowindex < 5)
-
{
-
-
if ($colindex < 5)
-
{
-
$sumindexes = $colindex + $rowindex;
-
-
}
-
else
-
{
-
$colindex = 0;
-
}
-
$colindex++;
-
$rowindex++;
-
}
-
-
else
-
{
-
$rowindex = 0;
-
-
}
-
-
print_r($array[$rowindex][$colindex]);
-
-
}
-
2 1131
1) Why make it difficult on yourself by using only one loop when 2 loops work just as well?
2) You're calculating the row and column indexes incorrectly.
3) It's much easier to calculate the indexes using integer division for one and mod for the other.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bob Bedford |
last post by:
I've this structure in a XML file:
Type
Model
Detail
Datas
Datas
Datas
Datas
/Detail
Detail
|
by: Charles Alexander |
last post by:
Hello
I am new to php & MySQL - I am trying to retrieve some records from a MySQL
table and redisplay them. The data in list form looks like this:
Sample_ID Marker_ID Variation
...
|
by: Craig Keightley |
last post by:
I have the following form
<FORM NAME="form1" METHOD="POST">
<?php do { ?>
<input name="approve" type="checkbox" id="approve" value="<?php echo
$row_rs; ?>">
<select name="select">
<option...
|
by: Bob Bedford |
last post by:
I've a directory structure where I store images.
0-999:
images/0/
then
images/0/0/
then
images/0/0/0-1.jpg
images/0/0/0-2.jpg
images/0/0/0-3.jpg
|
by: Limpor |
last post by:
Hi there,
I’m working on a freeCell homework, there are 8 piles in the tableau (which is an array of Pile objects), and i need go through a loop, and take a card from the deck , and put it into...
|
by: Amy |
last post by:
Hello, I have an array with 60 items in it, one for every second, But
when it gets to the end of the 60 items it stops. How do I get it to
start over when it gets to the end of the array? Please...
|
by: phattymatty |
last post by:
I am having trouble getting this loop to do what I would like it to. I need to display information from a multidimensional array in order. The order has already
been sorted in the array using a...
|
by: Cainnech |
last post by:
Hi guys,
It's me again. Arrays are a mindbuster for me. I'm stuck again but I can't see the error.
<HTML>
<HEAD>
<SCRIPT>
var lotto = ;
var winst = ;
|
by: eDaddi |
last post by:
I can't figure out why I cant get this simple loop to work. I'm using it to validate a form. I thought I could put the required field names in an array, loop through the array and have the it check...
|
by: Sjoerd |
last post by:
On Mon, 08 Sep 2008 00:11:38 -0700, mouac01@yahoo.com wrote:
Loop through the array and make an array of all keys. Then loop through
the array again and add the missing keys.
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |