PHP: cannot matching string "<br />
I'm having problems with string matching in PHP.
I've 2 html elements in my page, I've copy pasted here the content with Firebug
<div class="field-item odd">
<div class="field-label-inline-first">
Year:</div>
2009 </div>
<div class="field-item odd">
<div class="field-label-inline-first">
Synopsis:</div>
<br />
</div>
This php line works perfectly (the element with 2009 is detected)
<?php if ($items[0]['view'] == '2009') : echo "ok"; ?>
However I'm not able to match the string cont开发者_运维问答aining
element:<?php if ($items[0]['view'] == '<br />') : echo "ok"; ?> //doesn't work
<?php if ($items[0]['view'] == '<br />') : echo "ok"; ?> //again doesn't work
any tip ?
To give you some context: The strings are produced by CKEditor, an editor I'm using in my Drupal back-end. When I leave empty this editor, the
tag is displayed on the string as plain text (because I set "plain text" as formatting option in the back-end)Thanks
<br />
and <br />
are not the same thing - from the looks of it, your <
and >
tags are in a different format than what you're searching for.
Either search for <br />
or use html_entity_decode()
on your text.
did you try trimming it?
<?php if (trim($items[0]['view']) == '<br />') : echo "ok"; ?>
精彩评论