1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

strpos double arrays?

Discussion in 'PHP' started by kevydesigns, Jun 19, 2011.

  1. #1
    I have 2 arrays and want to see if $responseresult['Url'] contains $bannedkeys and do something about it?

    So far I got this:


    foreach ($allresponseresults as $responseresult){
    if(strpos($responseresult['Url'], $bannedkeys[0]) !== false)
    {
    }
    else
    {
    }
    PHP:
    As you can see, I had to define $bannedkeys[0] with a 0 index.. How would I code it so It checks all indexes of $bannedkeys?

    I tried another foreach loop and somehow cant get it to work.
    Please help Thanks!
     
    kevydesigns, Jun 19, 2011 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    double check on the parameter i may be wrong, but i think the array haystack would be the second parameter
     
    bartolay13, Jun 19, 2011 IP
  3. kevydesigns

    kevydesigns Well-Known Member

    Messages:
    1,209
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Nope, tried both and it gave me errors
     
    kevydesigns, Jun 20, 2011 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    are you trying to get the keys of the banned keys? i mean the array indexes?

     
    bartolay13, Jun 20, 2011 IP
  5. kevydesigns

    kevydesigns Well-Known Member

    Messages:
    1,209
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    125
    #5
    hmm..

    $bannedkeys is an array

    {
    $bannedkeys = array(
    "test.com",
    "google.com",
    );

    $responseresult is an array too..
    So I want it to check if there are banned keys (domain) in $responseresult['Url']

    So it will loop and check if each url contains any banned keys.
     
    kevydesigns, Jun 20, 2011 IP
  6. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #6
    ahh i see, try the code (in my second post) i posted
     
    bartolay13, Jun 20, 2011 IP
  7. kevydesigns

    kevydesigns Well-Known Member

    Messages:
    1,209
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    125
    #7
    No not count..

    I want to do something if it finds that a certain $responseresult['Url'] contains a banned key.
     
    kevydesigns, Jun 20, 2011 IP
  8. kevydesigns

    kevydesigns Well-Known Member

    Messages:
    1,209
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    125
    #8
    kevydesigns, Jun 20, 2011 IP