Jump to content

Archived

This topic is now archived and is closed to further replies.

visken

arrays in PHP

Recommended Posts

Hi all,

I am new to PHP and need your help to contruct the following array:
(n is number of user and m is number of movies)
[code]
array ([1]=>array([1]=>0/1
                         [2]=>0/1
                         [3]=>0/1
                   ...
                         [m]=>0/1
array ([2]=>array([1]=>0/1
                         [2]=>0/1
                         [3]=>0/1
                   ...
                         [m]=>0/1
......
array ([n]=>array([1]=>0/1
                         [2]=>0/1
                         [3]=>0/1
                   ...
                         [m]=>0/1

[/code]
Do you have any idea how I can make this work in PHP?

Thank you for your help!!!

Share this post


Link to post
Share on other sites
[code]
$m = '0/1';

$x = 5; //number of n's
$y = 5; //number of m's

for ($count1 = 0;$count1 < $x;$count1++) {
   for ($count2 = 0;$count2 < $y; $count2++) {
      $blah2[] = $m;
   }
   $blah1[] = $blah2;
}
[/code]

p.s.- you shouldn't double post threads. instead, try to be clearer in your first thread

Share this post


Link to post
Share on other sites
ok thank you.

But I want the index of the array started at 1 instead of 0. Any idea how to do that?

[!--quoteo(post=384167:date=Jun 15 2006, 03:32 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 15 2006, 03:32 PM) [snapback]384167[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$m = '0/1';

$x = 5; //number of n's
$y = 5; //number of m's

for ($count1 = 0;$count1 < $x;$count1++) {
   for ($count2 = 0;$count2 < $y; $count2++) {
      $blah2[] = $m;
   }
   $blah1[] = $blah2;
}
[/code]

p.s.- you shouldn't double post threads. instead, try to be clearer in your first thread
[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.