Mr.Mostafa Posted June 8, 2019 Share Posted June 8, 2019 سلام عليكم ابي اجيب القيمة الثانية من الجدول عن طريق القيمة الاولي يعني مثلا انا عندي جدول كدا local test = { [1] = {"1","2"}, [2] = {"3","4"}, } وابي اجيب قيمة 2 , عن طريق قيمة 1 يعني ابحث في الجدول عن طريق 1 مثال مثلا 2 = test[find(1)][1] Link to comment
Abdul KariM Posted June 8, 2019 Share Posted June 8, 2019 الحين عندك بالجدول القيمة الاولى فيها 1 و 2 انت جبت 1 وتبي تجيب 2 ؟ Link to comment
Mr.Mostafa Posted June 8, 2019 Author Share Posted June 8, 2019 3 minutes ago, Abdul KariM said: الحين عندك بالجدول القيمة الاولى فيها 1 و 2 انت جبت 1 وتبي تجيب 2 ؟ انا معايا الكولمن رقم 1 من الجدول الي هو "1" ابي اجيب الكولمن التاني عن طريق الكولمن الاول Link to comment
nxFairlywell Posted June 9, 2019 Share Posted June 9, 2019 (edited) local test = {}; test[1]={"1","2"}; test[2]={"3","4"}; function getSecondValueByFirstValue(firstValue,aTable) if (firstValue and aTable) then for i=1,#aTable do if (aTable[i][1] == firstValue) then return aTable[i][2] end end end return false end --> Example | مثال print( getSecondValueByFirstValue("3",test) ); -- prints --> 4 Edited June 9, 2019 by NX_CI Link to comment
Mr.Mostafa Posted June 9, 2019 Author Share Posted June 9, 2019 43 minutes ago, NX_CI said: local test = {}; test[1]={"1","2"}; test[2]={"3","4"}; function getSecondValueByFirstValue(firstValue,aTable) if (firstValue and aTable) then for i=1,#aTable do if (aTable[i][1] == firstValue) then return aTable[i][2] end end end return false end --> Example | مثال print( getSecondValueByFirstValue("3",test) ); -- prints --> 4 مع اني جبتها بس كفو علي الوظيفة ض2 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now