I know almost nothing about php, and I can't for the life of me figure out how to translate this correctly. Here's a perl version of what I want to do in php: $request = "$ENV{'REQUEST_URI'}"; if (($request ne "/")&&($request !~ m/index.php/)) {print $myadsensecode;} Code (markup): Here is the PHP code I have now: <!-- ONLY SHOW THIS TEXT ON SUB PAGES --> <?php $AC_Onlyshow = $_SERVER['REQUEST_URI']; $ADSENSE_CODE = <<<ADSENSECODE <div style="display:block;float:left;padding:5px;"> <!-- ADSENSE BLOCK --> </div> ADSENSECODE; ?> <!-- END ONLY SHOW THIS TEXT ON SUB PAGES --> <!-- LATER ON IN THE PAGE --> <?php if ( $AC_Onlyshow != "/") { echo "$ADSENSE_CODE"; } ?> Code (markup): It's for a wordpress blog - I want the adsense to show up on individual pages, and that part works: but my problem is when searches are done: it'll show the adsense code for every post which would cause issues with Google . . . The only thing I need translated is this part: &&($request !~ m/index.php/) Any help would be appreciated. thanks.
I've tried bare bones Babelfish translation for &&($request !~ m/index.php/) and got that: && ( strpos($request,'index.php') === false ) Code (markup): Hope that helps.
Hi, I tried the above code. . . and wordpress didn't like it too much. I think what I'm looking for is something that uses preg_match - but I don't know how to create regular expressions in php - only perl. Nor do I know how to do the if ((!$something)&&($not eq "$somethingelse")) {&whatever;} - I'm not exactly sure if the && is correct. Any more ideas on this?
I found what I was looking for, and I wanted to post the solution here in case someone else was looking for it to. Here is the translation of what I was looking for: <?php if ( $AC_Onlyshow != '/' && (!preg_match("/\/index.php+?/","$AC_Onlyshow"))) { echo "$ADSENSE_CODE"; } ?> Code (markup): While this does what I was trying to do, namely removing the adsense code from the search page. . . it does nothing for the archives nor the category pages. . . . I guess maybe I should just look for an already developed plugin, but it was fun to try & pick up some php in the meantime. Thanks.