Newbie needs help with OR php

by 15 replies
18
I'm new to php and cannot get this to work. It works with a single strpos but not with || between them. I researched and cannot find the right format

Code:
if (strpos(,)) || (strpos(,))

{

echo ;

fwrite(,); 

  fwrite(,);  

}
Huh the forum striped out my variables, but I think you get the idea
#programming #newbie #php
  • Cannot tell without the variables included but it should work:

    IF( strpos($haystack, $needle) || strpos($haystack, $needle) ) {
    // it is found so do something
    }
    • [ 1 ] Thanks
  • Notice the subtle difference between the use of parenthesis in the first line of each of the two posts. You don't need parens around the individual strpos() calls, but you certainly do need a pair around the entire test. I'm not even sure that the OP's first line would compile correctly, much less run. Try using the structure posed by Big Squid.
    • [1] reply
    • The parentheses continue to elude some logic to me, but I know they must be equal (( ))

      so I'm working on their logic. I got the problem solved and would like to thank everyone.

      Rick
      • [1] reply
  • David has it spot on here.

    The bolded red brackets below are not needed. Remove them and the code should run fine.

  • Could I ask you to please describe your intent in English, without symbols? Sorry to belabor the issue, but, (even with the full code showing), this still doesn't really communicate what it is you are trying to do. Thanks.
    • [1] reply
    • I understand, my genius friend whose helping me to learn this says I'm a slob.

      This is a Clickbank rss feed and page maker. This section is filtering for two keywords and checking for duplicates.

      Hope that helps.

      Rick
      • [1] reply

Next Topics on Trending Feed

  • 18

    I'm new to php and cannot get this to work. It works with a single strpos but not with || between them. I researched and cannot find the right format Code: if (strpos(,)) || (strpos(,)) { echo ; fwrite(,); fwrite(,); } Huh the forum striped out my variables, but I think you get the idea