Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-10-2009, 06:55 PM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
Efficient way to match unordered arrays?

I have a function which I am entering an array, and the job of the function is to match the entered array to an array within the list. It looks a little something like this...

PHP Code:
function Testarry ) {
  
temp.list = {
  {
"Test One""Test Two"},"String One",
  {
"Test Three""Test One"},"String Two",
  {
"Test Three""Test Two"},"String Three"
  
};
  
//matching script should go here
  
return appropriate string;

Thing is I can't compare them directly. Because the fed array may be in a different order. For example, if 'arry' is {"Test Two", "Test One"} I still need it two return "String One".
If there are no matches, OR if 'arry' contains a match but has extra items which are not in the list (i.e {"Test One", "Test Two", "Test Three"}) it should return false.

I could probably do some magic and come up with a way to match these, but I'd like to see some of your ideas to match them as there is probably a much better way then what I would do.

Thanks
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.