Even from time to time I get thrown astray on a weird bug in which I am usually looking right at the problem, yet still can not figure out what is wrong.
This is my code:
<?
$subject = "<td width=\"150\" background=\"images/bg_menu.gif\" bgcolor=\"#CCCCCC\">
##if: SESSION_SHOWPREFS##<div class='ptrten' onClick='change_pref(\"STRSEL\")'><INPUT ##if: STRSEL##CHECKED##fi: STRSEL## TYPE=RADIO NAME=sgw VALUE='str'> STRSEL</div>
<div class='ptrten' onClick='change_pref(\"GAYSEL\")'><INPUT ##if: GAYSEL##CHECKED##fi: GAYSEL## TYPE=RADIO NAME=sgw VALUE='gay'> GAYSEL</div>
<div class='ptrten' onClick='change_pref(\"ANYSEL\")'><INPUT ##if: ANYSEL##CHECKED##fi: ANYSEL## TYPE=RADIO NAME=sgw VALUE='any'> ALLSEL</div>##fi: SESSION_SHOWPREFS##
##if: SESSION_HIDEPREFS##<span class='ptrten' onClick='unhide()'>>>> Set Preferences</span>##fi: SESSION_HIDEPREFS##'
";
#//now try to match the string...
$match_string = '/##if:[\s]*SESSION_SHOWPREFS##(.+)##fi:[\s]*SESSION_SHOWPREFS##/U';
$result = preg_match( $match_string, $subject, $captured );
if( $result === 0 ) print "\nResult returned as 0";
if( $result === false ) print "\nResult returned false";
#//just out of curiosity..
$it_is_false = false; $it_is_true = true;
print "\nFALSE: $it_is_false, TRUE: $it_is_true\n";
#//now the data...
print_r( $capture ); print "\n";
?>
this is my output:
-bash-2.05b$ php -e preg_test.php
Result returned as 0
FALSE: , TRUE: 1
-bash-2.05b$
Perhaps someone can tell me what I am overlooking here... I am expected it to return 1, and match the following section within the subject:
##if: SESSION_SHOWPREFS##<div class='ptrten' onClick='change_pref(\"STRSEL\")'><INPUT ##if: STRSEL##CHECKED##fi: STRSEL## TYPE=RADIO NAME=sgw VALUE='str'> STRSEL</div>
<div class='ptrten' onClick='change_pref(\"GAYSEL\")'><INPUT ##if: GAYSEL##CHECKED##fi: GAYSEL## TYPE=RADIO NAME=sgw VALUE='gay'> GAYSEL</div>
<div class='ptrten' onClick='change_pref(\"ANYSEL\")'><INPUT ##if: ANYSEL##CHECKED##fi: ANYSEL## TYPE=RADIO NAME=sgw VALUE='any'> ALLSEL</div>##fi: SESSION_SHOWPREFS##
Any help would be appreciated, thanks in advance
