473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multidimensional Array ?

296 100+
Please correct the multidimensional array "a" below -->


Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <?php
  5.  
  6. $input = explode(" ", $_POST['input']);
  7.  
  8. $row = $input[0];
  9. $col = $input[1];
  10.  
  11. $k=2;
  12. $a = array();
  13.  
  14. for($i=0; $i<$row; $i++) {
  15. for($j=0; $i<$col; $i++) {
  16.     $a[$i][$j] = $input[$k];
  17.     $k++;
  18. }
  19. }
Apr 3 '07 #1
4 1311
r035198x
13,262 8TB
Please correct the multidimensional array "a" below -->


Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <?php
  5.  
  6. $input = explode(" ", $_POST['input']);
  7.  
  8. $row = $input[0];
  9. $col = $input[1];
  10.  
  11. $k=2;
  12. $a = array();
  13.  
  14. for($i=0; $i<$row; $i++) {
  15. for($j=0; $i<$col; $i++) {
  16.     $a[$i][$j] = $input[$k];
  17.     $k++;
  18. }
  19. }
What's wrong with it?
Apr 3 '07 #2
pankajit09
296 100+
What's wrong with it?

Will the multidimensional array "a" be globally available ?

global $a ;
Apr 4 '07 #3
code green
1,726 Expert 1GB
I don't see why not. What is the problem
Apr 4 '07 #4
Atli
5,058 Expert 4TB
What kind of data does $_Post['Input'] contain?

P.S. Your second for loop adds to the index of the first one.
Apr 4 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: TLOlczyk | last post by:
I have a brain cramp and I need some help. I have a chunk of code below which demonstrates a problem I have with multidimensional arrays. I want to keep it simple but something specific is...
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
2
by: chris | last post by:
Hi there, I created a Multidimensional array of labels Label lblMultiArray = new Label { {Label3, LblThuTotal}, {Label4,LblFriTotal} }; Now I would like to compare the values in the array,...
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
1
by: Chuy08 | last post by:
If I have a multidimensional array like the following: Array $records =Array 0 = 30 year, 6.0; 1 = 30 year, 6.0; 2 = Pay Option, 1.0; 3 = Pay Option, 1.0; How could I flatten this to...
5
by: LittleCake | last post by:
Hi All, I have a multidimensional array where each sub-array contains just two entries, which indicates a relationship between those two entries. for example the first sub-array: =Array ( =30...
4
Jezternz
by: Jezternz | last post by:
First of all I am open to any suggestions and advice. If a javscript multidimensional array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it...
12
by: filippo nanni | last post by:
Hello everybody, my question is this: I have two multidimensional arrays and I have to create a third one (for later use) from comparing these two. Here is my example code: //BEGIN CODE var...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.