visken Posted June 15, 2006 Share Posted June 15, 2006 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/1array ([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!!! Quote Link to comment https://forums.phpfreaks.com/topic/12062-arrays-in-php/ Share on other sites More sharing options...
.josh Posted June 15, 2006 Share Posted June 15, 2006 [code]$m = '0/1';$x = 5; //number of n's$y = 5; //number of m'sfor ($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-45885 Share on other sites More sharing options...
visken Posted June 15, 2006 Author Share Posted June 15, 2006 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'sfor ($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] Quote Link to comment https://forums.phpfreaks.com/topic/12062-arrays-in-php/#findComment-45894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.