use loop and in_array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    use loop and in_array

    so i have to seperate tables in a db, one is a kind of like a friends list and the other is used for page connections (people who have subscribed to a particular page on the website).

    will it be possible to loop the in_array function so i can check the array from the page connections with the array from the friends list?
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    #2
    ok i found example of a in_array loop... but im guessing for what i need i will have to use while instead of if? is this correct?

    if(in_array($va l['table_name'],$tables))
    {
    //Some Code
    }

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Hi, anfetienne. Nice to see you again :)

      You'll have to clarify your issue for me as I'm having trouble understanding it.

      Can you provide some sample data, and show how that data should look post-processing.

      Cheers,
      Mark.

      Comment

      • anfetienne
        Contributor
        • Feb 2009
        • 424

        #4
        hey markus, it has been a while...

        basically the friends list is a string that gets stored in a database i use explode to turn it into an array. also there are pages, group pages and profiles where users can subscribe to this is also stored as a string and turned into an array using explode (rather than having rows of data it fits in 1 row and 2 columns.

        as a privacy setting i want to check one array against the other and if the usernames are in the page array then they can see the page but if not it states they need to be friends or subscribe to the page. that bit i have already im just buggy on what loop i need to use to check over the arrays i.e.

        while(in_array( $userNames,$sub scribers))
        {
        //Some Code
        }

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          you could try an intersection. i.e. use array_intersect () and check, whether the username of interest is in that array.

          Comment

          • anfetienne
            Contributor
            • Feb 2009
            • 424

            #6
            ill give it a go... thanks as always for the advice

            Comment

            Working...