Jump to content

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!!!
Link to comment
https://forums.phpfreaks.com/topic/12062-arrays-in-php/
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
Link to comment
https://forums.phpfreaks.com/topic/12062-arrays-in-php/#findComment-45885
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]
Link to comment
https://forums.phpfreaks.com/topic/12062-arrays-in-php/#findComment-45894
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.