paulman888888 Posted October 3, 2009 Share Posted October 3, 2009 hi; First off thankyou for reading my post! I have been trying to match some array's but am not that good at it Below is the code! F = new Array();// Create some where to put all the questions F[0] = new Array(); // Create a question F[0][0] = 'Purchasing'; // Right-hand side text F[0][1] = 1;// Question ID F[1] = new Array();// Create a question F[1][0] = 'Human resources';// Right-hand side text F[1][1] = 2;// Question ID F[2] = new Array();// Create a question F[2][0] = 'Manufacturing or production';// Right-hand side text F[2][1] = 3;// Question ID F[3] = new Array();// Create a question F[3][0] = 'Marketing';// Right-hand side text F[3][1] = 4;// Question ID F[4] = new Array();// Create a question F[4][0] = 'Distribution';// Right-hand side text F[4][1] = 5;// Question ID F[5] = new Array();// Create a question F[5][0] = 'Sales';// Right-hand side text F[5][1] = 6;// Question ID F[6] = new Array();// Create a question F[6][0] = 'Research and development';// Right-hand side text F[6][1] = 7;// Question ID F[7] = new Array();// Create a question F[7][0] = 'Personnel';// Right-hand side text F[7][1] = 8;// Question ID F[8] = new Array();// Create a question F[8][0] = 'Customer services';// Right-hand side text F[8][1] = 9;// Question ID F[9] = new Array();// Create a question F[9][0] = 'Advertising';// Right-hand side text F[9][1] = 10;// Question ID D = new Array(); Create Matching Answers D[0] = new Array(); // Create Matching Answer D[0][0] = 'Buying goods and services from suppliers and negotiating contracts for stock or materials'; // The Answer D[0][1] = 1;// Relative Question ID D[0][2] = 0;// Unknown D[1] = new Array(); // Create Matching Answer D[1][0] = 'Planning the use of staff'; // The Answer D[1][1] = 2;// Relative Question ID D[1][2] = 0;// Unknown D[2] = new Array(); // Create Matching Answer D[2][0] = 'Making the products that the company will sell'; // The Answer D[2][1] = 3;// Relative Question ID D[2][2] = 0;// Unknown D[3] = new Array(); // Create Matching Answer D[3][0] = 'Strategic planning based on market research, product redesign'; // The Answer D[3][1] = 4;// Relative Question ID D[3][2] = 0;// Unknown D[4] = new Array(); // Create Matching Answer D[4][0] = 'Ensuring products and services get to customers'; // The Answer D[4][1] = 5;// Relative Question ID D[4][2] = 0;// Unknown D[5] = new Array(); // Create Matching Answer D[5][0] = 'Making contact with customers and presenting the company\'s portfolio of products and services'; // The Answer D[5][1] = 6;// Relative Question ID D[5][2] = 0;// Unknown D[6] = new Array(); // Create Matching Answer D[6][0] = 'Developing new products and improving current ones'; // The Answer D[6][1] = 7;// Relative Question ID D[6][2] = 0;// Unknown D[7] = new Array(); // Create Matching Answer D[7][0] = 'Recruitment and selection of employees'; // The Answer D[7][1] = 8;// Relative Question ID D[7][2] = 0;// Unknown D[8] = new Array(); // Create Matching Answer D[8][0] = 'Handle enquiries, offer advice and support, and deal with complaints'; // The Answer D[8][1] = 9;// Relative Question ID D[8][2] = 0;// Unknown D[9] = new Array(); // Create Matching Answer D[9][0] = 'Physical promotion of goods and services with campaigns'; // The Answer D[9][1] = 10;// Relative Question ID D[9][2] = 0;// Unknown What am trying to do is get D[n][1] value then show F[value2][0] value "Matches With" D[n][0] n is the current number (the loop untill all is completed) value2 is the value that we got from D[n][1] Sorry if its not very clear! Thankyou All Paul Quote Link to comment Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 Unfortunately my JavaScript knowledge isn't great, I've written what I think you want in PHP. If it seems right, great, hopefully you can convert it. If you can't let me know and I'll give it a go, I'm not great with JavaScript though. foreach($f as $question) { foreach($d as $answer) { if($answer[1] == $question[1]) { print $question[0] . ' Matches With ' . $answer[0] . '<br />'; } } } Btw, the output is something like... Purchasing Matches With Buying goods and services from suppliers and negotiating contracts for stock or materials Human resources Matches With Planning the use of staff Manufacturing or production Matches With Making the products that the company will sell Marketing Matches With Strategic planning based on market research, product redesign Distribution Matches With Ensuring products and services get to customers Sales Matches With Making contact with customers and presenting the company's portfolio of products and services Research and development Matches With Developing products and improving current ones Personnel Matches With Recruitment and selection of employees Customer services Matches With Handle enquiries, offer advice and support, and deal with complaints Advertising Matches With Physical promotion of goods and services with campaigns Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted October 3, 2009 Author Share Posted October 3, 2009 Thankyou cags I did it in php and changed it to a table. I used javascript to forward to my php script. Thankyou again Paul Quote Link to comment 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.