开发者

PHP: cannot matching string "<br />

开发者 https://www.devze.com 2022-12-31 00:23 出处:网络
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

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>
                                        &lt;br /&gt;
                            </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'] == '&lt;br /&gt;') : 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


&lt;br /&gt; 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 &lt;br /&gt; or use html_entity_decode() on your text.


did you try trimming it?

<?php if (trim($items[0]['view']) == '&lt;br /&gt;') : echo "ok"; ?> 
0

精彩评论

暂无评论...
验证码 换一张
取 消