Hello,

Can any one suggest me the logic for the following :

Now, I have the number stored in variable 'x' , 'y' and 'z' which is to be matched with the four set of numbers say four arrays.
I want to match this 'x' , y and 'z' with each array and print the output for each number matched.
note : no numbers or array will be of two digit.
also the array set is different for each variable 'x' and 'x' is ranging from 1 to 9.
i.e if x=1; the array set will be
a1={2,3,} a2={9,8} a3={4,7,6} a4={5}
the x and y can be anything ranging from 1 to 9.
now suppose if y=6 and z=2 then a1 and a3 should selected and the output should be the message which is written in number six and number 2.

and i f x is different the array set will be different.

can you suggest me simpler logic to do this.

If you have not understand the above script please let me know.

Thanking you!

    I think what you're looking for is [man]array_key_exists/man.

      thanks for our reply.

      But how can I use array_key_exists() function with the above logic.
      please let me know how can I intialize my array?

        I don't think I really understand what you want to do. Each time I read your initial post, I seem to get more confused. 😉

        Perhaps in addition to telling us what you are trying to do, it might help to also tell us why you want to do it. (Examples of before and after data may help, too.)

          ok,
          I am actually making a code which will do the numerological calculations.

          The user will be asked to enter his name, date of birth, month and year of birth.
          First the code will calculate the destiny number(using dob, mob and yob), name number(using name) and radical number(using date of birth).
          (all the numbers will be between 1to9)
          suppose dob is -28 then the radical no. will be = 2+8=10=1+0=1
          hence 1 will be the radical number.
          This way the name number and destiny number will be calculated.
          This much coding I have done.

          In numerology, each number i.e. from 1 to 9 has certain characteristics and they will have their friends, enemy's and neutral numbers from them.

          Suppose if name number is 1 and radical is 6 and destiny is 8;
          the name number will be now matched with the radical and destiny number to know if the radical and destiny number is the friend /enemy/neutral for the name number. And according to this the o/p wil be shown.

          Each number has different set of friends, enemy's and neutral number.
          For e.g.
          for name number : 1
          excellent number :{9}
          friends are { 4,8}
          Neutral are {2,3,5}
          enemy are{6,7}
          similarly for other set from 1-9.

          please suggest something.
          thanking you .

            You'll have to explain to us how you get the excellent number, friend numbers, neutral numbers, and enemy numbers out of the name number n. At the moment it looks like any partition of the set {1,2,3,4,5,6,7,8,9}-{n} will do.

            In other words, you're going to have to supply any logic that's involved.

              here,

              the excellent number, friends number, neutral number and enemy number is fixed for each name number ranging from 1 to 9.
              there is no logic behind this numbers, these are fixed.

              yeah;
              if for name number 1, the friend is 8 and enemy is 6
              then for name number 8 the friend will be 1 and for name number 6 enemy will be 1.

              thanking you!

                So then it's just array lookups:

                $friends = array(
                1=>array(4,8),
                //...

                And so on for the friends of other digits, and for the other categories, too.
                The friends of 1 are $friends[1]

                  thanks

                  Can you show me the three to four lines of coding in array.
                  As i don't know much about array in php.

                  Please...
                  Thanking you!

                    [man]array[/man]

                    $friends = array(
                    1=>array(4,8),
                    2=>array(1,9),
                    3=>array(6,5,2),
                    //...
                    );
                    
                      Write a Reply...